summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2022-05-26 12:53:32 +0200
committergit <svn-admin@ruby-lang.org>2022-05-28 19:22:54 +0900
commit6e3295e554aff8e48ff0a5a7aad587dce6d5bb29 (patch)
treee3b41f3a681fbce959e60fa86836c521785c1f4f
parente9c4e37f1f5c227aedd3d77b02d7591edc7897d2 (diff)
[rubygems/rubygems] Make code to find target update version easier to follow
https://github.com/rubygems/rubygems/commit/a7f81cc7ee
-rw-r--r--lib/rubygems/commands/update_command.rb36
1 files 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.
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.
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.
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.
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