diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2023-10-20 17:56:22 -0700 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-12-08 06:09:51 +0000 |
commit | 4817166e54ad98f9b3e9d06e9e8c7ccff992a957 (patch) | |
tree | f226bce0d78c12e867b6bbf63a876443f67c7a1c /spec/bundler/support/builders.rb | |
parent | 0166d56f2bb062ddf56a0e7757849da68b66fe62 (diff) |
[rubygems/rubygems] Extract generate_index command to rubygems-generate_index gem
So generate_index can be implemented with dependencies, such as the compact index
Took this approach from feedback in https://github.com/rubygems/rubygems/pull/6853
Running `gem generate_index` by default will use an installed rubygems-generate_index, or install and then use the command from the gem
Apply suggestions from code review
https://github.com/rubygems/rubygems/commit/fc1cb9bc9e
Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org>
Diffstat (limited to 'spec/bundler/support/builders.rb')
-rw-r--r-- | spec/bundler/support/builders.rb | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/spec/bundler/support/builders.rb b/spec/bundler/support/builders.rb index 76e05b5203..d36c5d4717 100644 --- a/spec/bundler/support/builders.rb +++ b/spec/bundler/support/builders.rb @@ -191,25 +191,25 @@ module Spec end end - def build_repo2(&blk) + def build_repo2(**kwargs, &blk) FileUtils.rm_rf gem_repo2 FileUtils.cp_r gem_repo1, gem_repo2 - update_repo2(&blk) if block_given? + update_repo2(**kwargs, &blk) if block_given? end # A repo that has no pre-installed gems included. (The caller completely # determines the contents with the block.) - def build_repo4(&blk) + def build_repo4(**kwargs, &blk) FileUtils.rm_rf gem_repo4 - build_repo(gem_repo4, &blk) + build_repo(gem_repo4, **kwargs, &blk) end def update_repo4(&blk) update_repo(gem_repo4, &blk) end - def update_repo2(&blk) - update_repo(gem_repo2, &blk) + def update_repo2(**kwargs, &blk) + update_repo(gem_repo2, **kwargs, &blk) end def build_security_repo @@ -227,12 +227,12 @@ module Spec end end - def build_repo(path, &blk) + def build_repo(path, **kwargs, &blk) return if File.directory?(path) FileUtils.mkdir_p("#{path}/gems") - update_repo(path, &blk) + update_repo(path,**kwargs, &blk) end def check_test_gems! @@ -249,7 +249,7 @@ module Spec end end - def update_repo(path) + def update_repo(path, build_compact_index: true) if path == gem_repo1 && caller.first.split(" ").last == "`build_repo`" raise "Updating gem_repo1 is unsupported -- use gem_repo2 instead" end @@ -258,7 +258,12 @@ module Spec @_build_repo = File.basename(path) yield with_gem_path_as Path.base_system_gem_path do - gem_command :generate_index, dir: path + Dir[Spec::Path.base_system_gem_path.join("gems/rubygems-generate_index*/lib")].first || + raise("Could not find rubygems-generate_index lib directory in #{Spec::Path.base_system_gem_path}") + + command = "generate_index" + command += " --no-compact" if !build_compact_index && gem_command(command + " --help").include?("--[no-]compact") + gem_command command, dir: path end ensure @_build_path = nil |