mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Let specs be sorted just once by the gem version promoter
https://github.com/rubygems/rubygems/commit/3cea25a39d
This commit is contained in:
parent
8d2bcc88ff
commit
6a21d196ba
3 changed files with 8 additions and 21 deletions
|
@ -116,15 +116,14 @@ module Bundler
|
|||
end
|
||||
|
||||
def sort_dep_specs(spec_groups, locked_spec)
|
||||
return spec_groups unless locked_spec
|
||||
@gem_name = locked_spec.name
|
||||
@locked_version = locked_spec.version
|
||||
@locked_version = locked_spec&.version
|
||||
@gem_name = locked_spec&.name
|
||||
|
||||
result = spec_groups.sort do |a, b|
|
||||
@a_ver = a.version
|
||||
@b_ver = b.version
|
||||
|
||||
unless @prerelease_specified[@gem_name]
|
||||
unless @gem_name && @prerelease_specified[@gem_name]
|
||||
a_pre = @a_ver.prerelease?
|
||||
b_pre = @b_ver.prerelease?
|
||||
|
||||
|
@ -148,7 +147,7 @@ module Bundler
|
|||
end
|
||||
|
||||
def either_version_older_than_locked
|
||||
@a_ver < @locked_version || @b_ver < @locked_version
|
||||
@locked_version && (@a_ver < @locked_version || @b_ver < @locked_version)
|
||||
end
|
||||
|
||||
def segments_do_not_match(level)
|
||||
|
@ -157,7 +156,7 @@ module Bundler
|
|||
end
|
||||
|
||||
def unlocking_gem?
|
||||
unlock_gems.empty? || unlock_gems.include?(@gem_name)
|
||||
unlock_gems.empty? || (@gem_name && unlock_gems.include?(@gem_name))
|
||||
end
|
||||
|
||||
# Specific version moves can't always reliably be done during sorting
|
||||
|
@ -165,7 +164,7 @@ module Bundler
|
|||
def post_sort(result)
|
||||
# default :major behavior in Bundler does not do this
|
||||
return result if major?
|
||||
if unlocking_gem?
|
||||
if unlocking_gem? || @locked_version.nil?
|
||||
result
|
||||
else
|
||||
move_version_to_end(result, @locked_version)
|
||||
|
|
|
@ -57,16 +57,12 @@ module Bundler
|
|||
# Search this index's specs, and any source indexes that this index knows
|
||||
# about, returning all of the results.
|
||||
def search(query)
|
||||
sort_specs(unsorted_search(query))
|
||||
end
|
||||
|
||||
def unsorted_search(query)
|
||||
results = local_search(query)
|
||||
|
||||
seen = results.map(&:full_name).uniq unless @sources.empty?
|
||||
|
||||
@sources.each do |source|
|
||||
source.unsorted_search(query).each do |spec|
|
||||
source.search(query).each do |spec|
|
||||
next if seen.include?(spec.full_name)
|
||||
|
||||
seen << spec.full_name
|
||||
|
@ -76,14 +72,6 @@ module Bundler
|
|||
|
||||
results
|
||||
end
|
||||
protected :unsorted_search
|
||||
|
||||
def sort_specs(specs)
|
||||
specs.sort_by do |s|
|
||||
platform_string = s.platform.to_s
|
||||
[s.version, platform_string == RUBY ? NULL : platform_string]
|
||||
end
|
||||
end
|
||||
|
||||
def local_search(query)
|
||||
case query
|
||||
|
|
|
@ -284,7 +284,7 @@ module Bundler
|
|||
end
|
||||
|
||||
def gem_not_found_message(name, requirement, source, extra_message = "")
|
||||
specs = source.specs.search(name)
|
||||
specs = source.specs.search(name).sort_by {|s| [s.version, s.platform.to_s] }
|
||||
matching_part = name
|
||||
requirement_label = SharedHelpers.pretty_dependency(requirement)
|
||||
cache_message = begin
|
||||
|
|
Loading…
Reference in a new issue