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
|
spec_tuples = fetch_remote_gems spec
|
||||||
|
|
||||||
highest_remote_gem = spec_tuples.max
|
highest_remote_gem = spec_tuples.max
|
||||||
|
return unless highest_remote_gem
|
||||||
highest_remote_gem ||= [Gem::NameTuple.null]
|
|
||||||
|
|
||||||
highest_remote_gem.first
|
highest_remote_gem.first
|
||||||
end
|
end
|
||||||
|
@ -210,30 +209,22 @@ command to remove old versions.
|
||||||
version = options[:system]
|
version = options[:system]
|
||||||
update_latest = version == true
|
update_latest = version == true
|
||||||
|
|
||||||
if update_latest
|
unless update_latest
|
||||||
version = Gem::Version.new Gem::VERSION
|
|
||||||
requirement = Gem::Requirement.new ">= #{Gem::VERSION}"
|
|
||||||
else
|
|
||||||
version = Gem::Version.new version
|
version = Gem::Version.new version
|
||||||
requirement = Gem::Requirement.new version
|
requirement = Gem::Requirement.new version
|
||||||
|
|
||||||
|
return version, requirement
|
||||||
end
|
end
|
||||||
|
|
||||||
|
version = Gem::Version.new Gem::VERSION
|
||||||
|
requirement = Gem::Requirement.new ">= #{Gem::VERSION}"
|
||||||
|
|
||||||
rubygems_update = Gem::Specification.new
|
rubygems_update = Gem::Specification.new
|
||||||
rubygems_update.name = 'rubygems-update'
|
rubygems_update.name = 'rubygems-update'
|
||||||
rubygems_update.version = version
|
rubygems_update.version = version
|
||||||
|
|
||||||
hig = {
|
highest_remote_tup = highest_remote_name_tuple(rubygems_update)
|
||||||
'rubygems-update' => rubygems_update,
|
target = highest_remote_tup ? highest_remote_tup.version : version
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
return target, requirement
|
return target, requirement
|
||||||
end
|
end
|
||||||
|
@ -302,7 +293,7 @@ command to remove old versions.
|
||||||
args
|
args
|
||||||
end
|
end
|
||||||
|
|
||||||
def which_to_update(highest_installed_gems, gem_names, system = false)
|
def which_to_update(highest_installed_gems, gem_names)
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
highest_installed_gems.each do |l_name, l_spec|
|
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 }
|
gem_names.none? {|name| name == l_spec.name }
|
||||||
|
|
||||||
highest_remote_tup = highest_remote_name_tuple l_spec
|
highest_remote_tup = highest_remote_name_tuple l_spec
|
||||||
highest_remote_ver = highest_remote_tup.version
|
next unless highest_remote_tup
|
||||||
highest_installed_ver = l_spec.version
|
|
||||||
|
|
||||||
if system or (highest_installed_ver < highest_remote_ver)
|
result << highest_remote_tup
|
||||||
result << Gem::NameTuple.new(l_spec.name, [highest_installed_ver, highest_remote_ver].max, highest_remote_tup.platform)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|
Loading…
Add table
Reference in a new issue