diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-01-18 20:36:31 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-01-26 12:50:39 +0900 |
commit | 17f5631c6ea118b9ce0e8776dc50c7b1dcdaf596 (patch) | |
tree | 93cc91fcdd336690d7d7e3862fa02415f4f4cce1 /tool/lib/bundled_gem.rb | |
parent | 78fcc9847a9db6d42c8c263154ec05903a370b6b (diff) | |
download | ruby-17f5631c6ea118b9ce0e8776dc50c7b1dcdaf596.tar.gz |
[Bug #19340] Fix bundle gems with test revision
Build temporary gem package from cloned repository if test revision is
set.
Diffstat (limited to 'tool/lib/bundled_gem.rb')
-rw-r--r-- | tool/lib/bundled_gem.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tool/lib/bundled_gem.rb b/tool/lib/bundled_gem.rb index 38c331183d..46183ba06c 100644 --- a/tool/lib/bundled_gem.rb +++ b/tool/lib/bundled_gem.rb @@ -14,6 +14,19 @@ module BundledGem puts "Unpacked #{file}" end + def build(gemspec, version, outdir = ".", validation: true) + outdir = File.expand_path(outdir) + gemdir, gemfile = File.split(gemspec) + Dir.chdir(gemdir) do + spec = Gem::Specification.load(gemfile) + abort "Failed to load #{gemspec}" unless spec + abort "Unexpected version #{spec.version}" unless spec.version == Gem::Version.new(version) + output = File.join(outdir, spec.file_name) + FileUtils.rm_rf(output) + Gem::Package.build(spec, validation == false, validation, output) + end + end + def copy(path, *rest) path, n = File.split(path) spec = Dir.chdir(path) {Gem::Specification.load(n)} or raise "Cannot load #{path}" |