summaryrefslogtreecommitdiff
path: root/tool/lib
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-01-18 20:36:31 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-01-26 12:50:39 +0900
commit17f5631c6ea118b9ce0e8776dc50c7b1dcdaf596 (patch)
tree93cc91fcdd336690d7d7e3862fa02415f4f4cce1 /tool/lib
parent78fcc9847a9db6d42c8c263154ec05903a370b6b (diff)
downloadruby-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')
-rw-r--r--tool/lib/bundled_gem.rb13
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}"