[前][次][番号順一覧][スレッド一覧]

ruby-changes:73456

From: Antonio <ko1@a...>
Date: Wed, 7 Sep 2022 06:19:09 +0900 (JST)
Subject: [ruby-changes:73456] 4c1f6750f2 (master): [rubygems/rubygems] Fix: Gem info bug with version flag

https://git.ruby-lang.org/ruby.git/commit/?id=4c1f6750f2

From 4c1f6750f2c333be2adf7ceab644598b230606d2 Mon Sep 17 00:00:00 2001
From: Antonio Paulino <tonnyarauujo@g...>
Date: Mon, 29 Aug 2022 16:00:07 -0300
Subject: [rubygems/rubygems] Fix: Gem info bug with version flag

https://github.com/rubygems/rubygems/commit/e4cee1f975
---
 lib/rubygems/query_utils.rb                     |  4 ++--
 test/rubygems/test_gem_commands_info_command.rb | 26 +++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/lib/rubygems/query_utils.rb b/lib/rubygems/query_utils.rb
index a502717f94..c72955f83b 100644
--- a/lib/rubygems/query_utils.rb
+++ b/lib/rubygems/query_utils.rb
@@ -151,7 +151,7 @@ module Gem::QueryUtils https://github.com/ruby/ruby/blob/trunk/lib/rubygems/query_utils.rb#L151
       fetcher.detect(specs_type) { true }
     else
       fetcher.detect(specs_type) do |name_tuple|
-        name === name_tuple.name
+        name === name_tuple.name && options[:version].satisfied_by?(name_tuple.version)
       end
     end
 
@@ -159,7 +159,7 @@ module Gem::QueryUtils https://github.com/ruby/ruby/blob/trunk/lib/rubygems/query_utils.rb#L159
   end
 
   def specs_type
-    if options[:all]
+    if options[:all] || options[:version].specific?
       if options[:prerelease]
         :complete
       else
diff --git a/test/rubygems/test_gem_commands_info_command.rb b/test/rubygems/test_gem_commands_info_command.rb
index b18b405da6..1c9ab7b07c 100644
--- a/test/rubygems/test_gem_commands_info_command.rb
+++ b/test/rubygems/test_gem_commands_info_command.rb
@@ -40,4 +40,30 @@ class TestGemCommandsInfoCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_info_command.rb#L40
     assert_match %r{#{@gem.summary}\n}, @ui.output
     assert_match "", @ui.error
   end
+
+  def test_execute_with_version_flag
+    spec_fetcher do |fetcher|
+      fetcher.spec "coolgem", "1.0"
+      fetcher.spec "coolgem", "2.0"
+    end
+
+    @cmd.handle_options %w[coolgem --remote --version 1.0]
+
+    use_ui @ui do
+      @cmd.execute
+    end
+
+    expected = <<-EOF
+
+*** REMOTE GEMS ***
+
+coolgem (1.0)
+    Author: A User
+    Homepage: http://example.com
+
+    this is a summary
+    EOF
+
+    assert_equal expected, @ui.output
+  end
 end
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]