[rubygems/rubygems] Update vendored pub_grub

https://github.com/rubygems/rubygems/commit/3aaa75e7b9
This commit is contained in:
Hartley McGuire 2025-03-17 17:22:20 -04:00 committed by Hiroshi SHIBATA
parent afda30774c
commit ee7cfb1d1e
Notes: git 2025-03-24 04:25:31 +00:00
5 changed files with 39 additions and 31 deletions

View File

@ -164,7 +164,7 @@ module Bundler::PubGrub
sorted_versions[high] sorted_versions[high]
end end
range = VersionRange.new(min: low, max: high, include_min: true) range = VersionRange.new(min: low, max: high, include_min: !low.nil?)
self_constraint = VersionConstraint.new(package, range: range) self_constraint = VersionConstraint.new(package, range: range)

View File

@ -76,6 +76,9 @@ module Bundler::PubGrub
end end
def initialize(min: nil, max: nil, include_min: false, include_max: false, name: nil) def initialize(min: nil, max: nil, include_min: false, include_max: false, name: nil)
raise ArgumentError, "Ranges without a lower bound cannot have include_min == true" if !min && include_min == true
raise ArgumentError, "Ranges without an upper bound cannot have include_max == true" if !max && include_max == true
@min = min @min = min
@max = max @max = max
@include_min = include_min @include_min = include_min
@ -311,10 +314,19 @@ module Bundler::PubGrub
def contiguous_to?(other) def contiguous_to?(other)
return false if other.empty? return false if other.empty?
return true if any?
intersects?(other) || intersects?(other) || contiguous_below?(other) || contiguous_above?(other)
(min == other.max && (include_min || other.include_max)) || end
(max == other.min && (include_max || other.include_min))
def contiguous_below?(other)
return false if !max || !other.min
max == other.min && (include_max || other.include_min)
end
def contiguous_above?(other)
other.contiguous_below?(self)
end end
def allows_all?(other) def allows_all?(other)
@ -375,15 +387,15 @@ module Bundler::PubGrub
def invert def invert
return self.class.empty if any? return self.class.empty if any?
low = VersionRange.new(max: min, include_max: !include_min) low = -> { VersionRange.new(max: min, include_max: !include_min) }
high = VersionRange.new(min: max, include_min: !include_max) high = -> { VersionRange.new(min: max, include_min: !include_max) }
if !min if !min
high high.call
elsif !max elsif !max
low low.call
else else
low.union(high) low.call.union(high.call)
end end
end end

View File

@ -36,26 +36,25 @@ module Bundler::PubGrub
# Returns true if there is more work to be done, false otherwise # Returns true if there is more work to be done, false otherwise
def work def work
return false if solved? unsatisfied_terms = solution.unsatisfied
if unsatisfied_terms.empty?
next_package = choose_package_version
propagate(next_package)
if solved?
logger.info { "Solution found after #{solution.attempted_solutions} attempts:" } logger.info { "Solution found after #{solution.attempted_solutions} attempts:" }
solution.decisions.each do |package, version| solution.decisions.each do |package, version|
next if Package.root?(package) next if Package.root?(package)
logger.info { "* #{package} #{version}" } logger.info { "* #{package} #{version}" }
end end
false return false
else
true
end end
next_package = choose_package_version_from(unsatisfied_terms)
propagate(next_package)
true
end end
def solve def solve
work until solved? while work; end
solution.decisions solution.decisions
end end
@ -105,25 +104,21 @@ module Bundler::PubGrub
unsatisfied.package unsatisfied.package
end end
def next_package_to_try def next_term_to_try_from(unsatisfied_terms)
solution.unsatisfied.min_by do |term| unsatisfied_terms.min_by do |term|
package = term.package package = term.package
range = term.constraint.range range = term.constraint.range
matching_versions = source.versions_for(package, range) matching_versions = source.versions_for(package, range)
higher_versions = source.versions_for(package, range.upper_invert) higher_versions = source.versions_for(package, range.upper_invert)
[matching_versions.count <= 1 ? 0 : 1, higher_versions.count] [matching_versions.count <= 1 ? 0 : 1, higher_versions.count]
end.package end
end end
def choose_package_version def choose_package_version_from(unsatisfied_terms)
if solution.unsatisfied.empty? unsatisfied_term = next_term_to_try_from(unsatisfied_terms)
logger.info "No packages unsatisfied. Solving complete!" package = unsatisfied_term.package
return nil
end
package = next_package_to_try
unsatisfied_term = solution.unsatisfied.find { |t| t.package == package }
version = source.versions_for(package, unsatisfied_term.constraint.range).first version = source.versions_for(package, unsatisfied_term.constraint.range).first
logger.debug { "attempting #{package} #{version}" } logger.debug { "attempting #{package} #{version}" }

View File

@ -8,7 +8,7 @@ gem "net-http", "0.6.0"
gem "net-http-persistent", "4.0.4" gem "net-http-persistent", "4.0.4"
gem "net-protocol", "0.2.2" gem "net-protocol", "0.2.2"
gem "optparse", "0.6.0" gem "optparse", "0.6.0"
gem "pub_grub", github: "jhawthorn/pub_grub" gem "pub_grub", github: "jhawthorn/pub_grub", ref: "57d4f344366c8b86f7fe506e9bfa08f3c731e397"
gem "resolv", "0.6.0" gem "resolv", "0.6.0"
gem "securerandom", "0.4.1" gem "securerandom", "0.4.1"
gem "timeout", "0.4.3" gem "timeout", "0.4.3"

View File

@ -6,7 +6,8 @@ GIT
GIT GIT
remote: https://github.com/jhawthorn/pub_grub.git remote: https://github.com/jhawthorn/pub_grub.git
revision: 55a2d65c5c3176f72de5e25d59fb6f52b9fe60ef revision: 57d4f344366c8b86f7fe506e9bfa08f3c731e397
ref: 57d4f344366c8b86f7fe506e9bfa08f3c731e397
specs: specs:
pub_grub (0.5.0) pub_grub (0.5.0)