mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Make code to find target update version easier to follow
https://github.com/rubygems/rubygems/commit/a7f81cc7ee
This commit is contained in:
parent
e9c4e37f1f
commit
6e3295e554
1 changed files with 12 additions and 24 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue