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

ruby-changes:70884

From: loadkpi <ko1@a...>
Date: Sat, 15 Jan 2022 14:00:48 +0900 (JST)
Subject: [ruby-changes:70884] 7c70151aed (master): [rubygems/rubygems] Fix `gem update --system` for already installed version of rubygems-update

https://git.ruby-lang.org/ruby.git/commit/?id=7c70151aed

From 7c70151aedf5b51447f7a9ebcb6a4b58ef76deb2 Mon Sep 17 00:00:00 2001
From: loadkpi <loadkpi@g...>
Date: Fri, 14 Jan 2022 09:07:39 +0300
Subject: [rubygems/rubygems]  Fix `gem update --system` for already installed
 version of rubygems-update

https://github.com/rubygems/rubygems/commit/c167d513a7
---
 lib/rubygems/commands/update_command.rb           |  2 +-
 test/rubygems/test_gem_commands_update_command.rb | 34 +++++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index 3714b003227..99208e5cb2d 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -287,7 +287,7 @@ command to remove old versions. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/update_command.rb#L287
     check_oldest_rubygems version
 
     installed_gems = Gem::Specification.find_all_by_name 'rubygems-update', requirement
-    installed_gems = update_gem('rubygems-update', version) if installed_gems.empty?
+    installed_gems = update_gem('rubygems-update', version) if installed_gems.empty? || installed_gems.first.version != version
     return if installed_gems.empty?
 
     version = installed_gems.first.version
diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb
index ce599d5812d..c765e9a8df0 100644
--- a/test/rubygems/test_gem_commands_update_command.rb
+++ b/test/rubygems/test_gem_commands_update_command.rb
@@ -157,6 +157,40 @@ class TestGemCommandsUpdateCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_update_command.rb#L157
     assert_empty out
   end
 
+  def test_execute_system_update_installed
+    spec_fetcher do |fetcher|
+      fetcher.download 'rubygems-update', 8 do |s|
+        s.files = %w[setup.rb]
+      end
+    end
+
+    @cmd.options[:args]          = []
+    @cmd.options[:system]        = true
+
+    @cmd.execute
+
+    spec_fetcher do |fetcher|
+      fetcher.download 'rubygems-update', 9 do |s|
+        s.files = %w[setup.rb]
+      end
+    end
+
+    @cmd = Gem::Commands::UpdateCommand.new
+    @cmd.options[:args]          = []
+    @cmd.options[:system]        = true
+
+    use_ui @ui do
+      @cmd.execute
+    end
+
+    out = @ui.output.split "\n"
+    assert_equal "Updating rubygems-update", out.shift
+    assert_equal "Installing RubyGems 9", out.shift
+    assert_equal "RubyGems system software updated", out.shift
+
+    assert_empty out
+  end
+
   def test_execute_system_specific
     spec_fetcher do |fetcher|
       fetcher.download 'rubygems-update', 8 do |s|
-- 
cgit v1.2.1


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

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