From 9f812522f521bf4f3d550a84233a05d23e7dd5ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 8 Oct 2024 21:25:23 +0200 Subject: [PATCH] [rubygems/rubygems] Allow `gem pristine` to reset default gems too https://github.com/rubygems/rubygems/commit/c9e665eb8a --- lib/rubygems/commands/pristine_command.rb | 8 +++----- test/rubygems/test_gem_commands_pristine_command.rb | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb index 999c9fef0f..96e48df4e6 100644 --- a/lib/rubygems/commands/pristine_command.rb +++ b/lib/rubygems/commands/pristine_command.rb @@ -134,11 +134,8 @@ extensions will be restored. say "Restoring gems to pristine condition..." - specs.each do |spec| - if spec.default_gem? - say "Skipped #{spec.full_name}, it is a default gem" - next - end + specs.group_by(&:full_name_with_location).values.each do |grouped_specs| + spec = grouped_specs.find {|s| !s.default_gem? } || grouped_specs.first if options.key? :skip if options[:skip].include? spec.name @@ -188,6 +185,7 @@ extensions will be restored. env_shebang: env_shebang, build_args: spec.build_args, bin_dir: bin_dir, + install_as_default: spec.default_gem?, } if options[:only_executables] diff --git a/test/rubygems/test_gem_commands_pristine_command.rb b/test/rubygems/test_gem_commands_pristine_command.rb index b8b39133ff..190f78c79f 100644 --- a/test/rubygems/test_gem_commands_pristine_command.rb +++ b/test/rubygems/test_gem_commands_pristine_command.rb @@ -642,7 +642,8 @@ class TestGemCommandsPristineCommand < Gem::TestCase assert_equal( [ "Restoring gems to pristine condition...", - "Skipped default-2.0.0.0, it is a default gem", + "Cached gem for default-2.0.0.0 not found, attempting to fetch...", + "Skipped default-2.0.0.0, it was not found from cache and remote sources", ], @ui.output.split("\n") )