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

ruby-changes:71997

From: David <ko1@a...>
Date: Sat, 28 May 2022 19:23:07 +0900 (JST)
Subject: [ruby-changes:71997] 6e3295e554 (master): [rubygems/rubygems] Make code to find target update version easier to follow

https://git.ruby-lang.org/ruby.git/commit/?id=6e3295e554

From 6e3295e554aff8e48ff0a5a7aad587dce6d5bb29 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Thu, 26 May 2022 12:53:32 +0200
Subject: [rubygems/rubygems] Make code to find target update version easier to
 follow

https://github.com/rubygems/rubygems/commit/a7f81cc7ee
---
 lib/rubygems/commands/update_command.rb | 36 +++++++++++----------------------
 1 file changed, 12 insertions(+), 24 deletions(-)

diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index 0a53d1ce5a..422fdd4e81 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -163,8 +163,7 @@ command to remove old versions. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/update_command.rb#L163
     spec_tuples = fetch_remote_gems spec
 
     highest_remote_gem = spec_tuples.max
-
-    highest_remote_gem ||= [Gem::NameTuple.null]
+    return unless highest_remote_gem
 
     highest_remote_gem.first
   end
@@ -210,30 +209,22 @@ command to remove old versions. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/update_command.rb#L209
     version = options[:system]
     update_latest = version == true
 
-    if update_latest
-      version     = Gem::Version.new     Gem::VERSION
-      requirement = Gem::Requirement.new ">= #{Gem::VERSION}"
-    else
+    unless update_latest
       version     = Gem::Version.new     version
       requirement = Gem::Requirement.new version
+
+      return version, requirement
     end
 
+    version     = Gem::Version.new     Gem::VERSION
+    requirement = Gem::Requirement.new ">= #{Gem::VERSION}"
+
     rubygems_update         = Gem::Specification.new
     rubygems_update.name    = 'rubygems-update'
     rubygems_update.version = version
 
-    hig = {
-      'rubygems-update' => rubygems_update,
-    }
-
-    gems_to_update = which_to_update hig, options[:args], :system
-    up_ver = gems_to_update.first.version
-
-    target = if update_latest
-      up_ver
-    else
-      version
-    end
+    highest_remote_tup = highest_remote_name_tuple(rubygems_update)
+    target = highest_remote_tup ? highest_remote_tup.version : version
 
     return target, requirement
   end
@@ -302,7 +293,7 @@ command to remove old versions. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/update_command.rb#L293
     args
   end
 
-  def which_to_update(highest_installed_gems, gem_names, system = false)
+  def which_to_update(highest_installed_gems, gem_names)
     result = []
 
     highest_installed_gems.each do |l_name, l_spec|
@@ -310,12 +301,9 @@ command to remove old versions. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/update_command.rb#L301
               gem_names.none? {|name| name == l_spec.name }
 
       highest_remote_tup = highest_remote_name_tuple l_spec
-      highest_remote_ver = highest_remote_tup.version
-      highest_installed_ver = l_spec.version
+      next unless highest_remote_tup
 
-      if system or (highest_installed_ver < highest_remote_ver)
-        result << Gem::NameTuple.new(l_spec.name, [highest_installed_ver, highest_remote_ver].max, highest_remote_tup.platform)
-      end
+      result << highest_remote_tup
     end
 
     result
-- 
cgit v1.2.1


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

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