diff options
author | David RodrÃguez <[email protected]> | 2024-07-23 18:52:03 +0200 |
---|---|---|
committer | git <[email protected]> | 2024-07-30 14:01:43 +0000 |
commit | 1164b6a7baeddade88b9eb01c3ac00f83d2066c6 (patch) | |
tree | 33bbcf537524d17c7eacf6e72e5f4b0e2fa99e5f | |
parent | 3d248b2eb3d2b10f9d2ddf614485ceb35089f924 (diff) |
[rubygems/rubygems] Fix `gem list` regression when a regular gem shadows a default one
Previously, if you have bundler installed both as a regular gem and a
default gem, the default gem would be displayed by `gem list`.
https://github.com/rubygems/rubygems/commit/10a6b1736e
-rw-r--r-- | lib/rubygems/query_utils.rb | 2 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_list_command.rb | 29 |
2 files changed, 28 insertions, 3 deletions
diff --git a/lib/rubygems/query_utils.rb b/lib/rubygems/query_utils.rb index a95a759401..ea05969422 100644 --- a/lib/rubygems/query_utils.rb +++ b/lib/rubygems/query_utils.rb @@ -132,7 +132,7 @@ module Gem::QueryUtils version_matches = show_prereleases? || !s.version.prerelease? name_matches && version_matches - end + end.uniq(&:full_name) spec_tuples = specs.map do |spec| [spec.name_tuple, spec] diff --git a/test/rubygems/test_gem_commands_list_command.rb b/test/rubygems/test_gem_commands_list_command.rb index c83dd51b67..0b52b54e77 100644 --- a/test/rubygems/test_gem_commands_list_command.rb +++ b/test/rubygems/test_gem_commands_list_command.rb @@ -8,7 +8,9 @@ class TestGemCommandsListCommand < Gem::TestCase super @cmd = Gem::Commands::ListCommand.new + end + def test_execute_installed spec_fetcher do |fetcher| fetcher.spec "c", 1 end @@ -16,9 +18,7 @@ class TestGemCommandsListCommand < Gem::TestCase @fetcher.data["#{@gem_repo}Marshal.#{Gem.marshal_version}"] = proc do raise Gem::RemoteFetcher::FetchError end - end - def test_execute_installed @cmd.handle_options %w[c --installed] assert_raise Gem::MockGemUi::SystemExitException do @@ -30,4 +30,29 @@ class TestGemCommandsListCommand < Gem::TestCase assert_equal "true\n", @ui.output assert_equal "", @ui.error end + + def test_execute_normal_gem_shadowing_default_gem + c1_default = new_default_spec "c", 1 + install_default_gems c1_default + + c1 = util_spec("c", 1) {|s| s.date = "2024-01-01" } + install_gem c1 + + Gem::Specification.reset + + @cmd.handle_options %w[c] + + use_ui @ui do + @cmd.execute + end + + expected = <<-EOF + +*** LOCAL GEMS *** + +c (1) +EOF + + assert_equal expected, @ui.output + end end |