Skip to content

Commit ee7cfb1

Browse files
skipkayhilhsbt
authored andcommitted
[rubygems/rubygems] Update vendored pub_grub
ruby/rubygems@3aaa75e7b9
1 parent afda307 commit ee7cfb1

File tree

5 files changed

+39
-31
lines changed

5 files changed

+39
-31
lines changed

lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def incompatibilities_for(package, version)
164164
sorted_versions[high]
165165
end
166166

167-
range = VersionRange.new(min: low, max: high, include_min: true)
167+
range = VersionRange.new(min: low, max: high, include_min: !low.nil?)
168168

169169
self_constraint = VersionConstraint.new(package, range: range)
170170

lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def self.any
7676
end
7777

7878
def initialize(min: nil, max: nil, include_min: false, include_max: false, name: nil)
79+
raise ArgumentError, "Ranges without a lower bound cannot have include_min == true" if !min && include_min == true
80+
raise ArgumentError, "Ranges without an upper bound cannot have include_max == true" if !max && include_max == true
81+
7982
@min = min
8083
@max = max
8184
@include_min = include_min
@@ -311,10 +314,19 @@ def union(other)
311314

312315
def contiguous_to?(other)
313316
return false if other.empty?
317+
return true if any?
318+
319+
intersects?(other) || contiguous_below?(other) || contiguous_above?(other)
320+
end
321+
322+
def contiguous_below?(other)
323+
return false if !max || !other.min
324+
325+
max == other.min && (include_max || other.include_min)
326+
end
314327

315-
intersects?(other) ||
316-
(min == other.max && (include_min || other.include_max)) ||
317-
(max == other.min && (include_max || other.include_min))
328+
def contiguous_above?(other)
329+
other.contiguous_below?(self)
318330
end
319331

320332
def allows_all?(other)
@@ -375,15 +387,15 @@ def upper_invert
375387
def invert
376388
return self.class.empty if any?
377389

378-
low = VersionRange.new(max: min, include_max: !include_min)
379-
high = VersionRange.new(min: max, include_min: !include_max)
390+
low = -> { VersionRange.new(max: min, include_max: !include_min) }
391+
high = -> { VersionRange.new(min: max, include_min: !include_max) }
380392

381393
if !min
382-
high
394+
high.call
383395
elsif !max
384-
low
396+
low.call
385397
else
386-
low.union(high)
398+
low.call.union(high.call)
387399
end
388400
end
389401

lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,25 @@ def solved?
3636

3737
# Returns true if there is more work to be done, false otherwise
3838
def work
39-
return false if solved?
40-
41-
next_package = choose_package_version
42-
propagate(next_package)
43-
44-
if solved?
39+
unsatisfied_terms = solution.unsatisfied
40+
if unsatisfied_terms.empty?
4541
logger.info { "Solution found after #{solution.attempted_solutions} attempts:" }
4642
solution.decisions.each do |package, version|
4743
next if Package.root?(package)
4844
logger.info { "* #{package} #{version}" }
4945
end
5046

51-
false
52-
else
53-
true
47+
return false
5448
end
49+
50+
next_package = choose_package_version_from(unsatisfied_terms)
51+
propagate(next_package)
52+
53+
true
5554
end
5655

5756
def solve
58-
work until solved?
57+
while work; end
5958

6059
solution.decisions
6160
end
@@ -105,25 +104,21 @@ def propagate_incompatibility(incompatibility)
105104
unsatisfied.package
106105
end
107106

108-
def next_package_to_try
109-
solution.unsatisfied.min_by do |term|
107+
def next_term_to_try_from(unsatisfied_terms)
108+
unsatisfied_terms.min_by do |term|
110109
package = term.package
111110
range = term.constraint.range
112111
matching_versions = source.versions_for(package, range)
113112
higher_versions = source.versions_for(package, range.upper_invert)
114113

115114
[matching_versions.count <= 1 ? 0 : 1, higher_versions.count]
116-
end.package
115+
end
117116
end
118117

119-
def choose_package_version
120-
if solution.unsatisfied.empty?
121-
logger.info "No packages unsatisfied. Solving complete!"
122-
return nil
123-
end
118+
def choose_package_version_from(unsatisfied_terms)
119+
unsatisfied_term = next_term_to_try_from(unsatisfied_terms)
120+
package = unsatisfied_term.package
124121

125-
package = next_package_to_try
126-
unsatisfied_term = solution.unsatisfied.find { |t| t.package == package }
127122
version = source.versions_for(package, unsatisfied_term.constraint.range).first
128123
logger.debug { "attempting #{package} #{version}" }
129124

tool/bundler/vendor_gems.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
gem "net-http-persistent", "4.0.4"
99
gem "net-protocol", "0.2.2"
1010
gem "optparse", "0.6.0"
11-
gem "pub_grub", github: "jhawthorn/pub_grub"
11+
gem "pub_grub", github: "jhawthorn/pub_grub", ref: "57d4f344366c8b86f7fe506e9bfa08f3c731e397"
1212
gem "resolv", "0.6.0"
1313
gem "securerandom", "0.4.1"
1414
gem "timeout", "0.4.3"

tool/bundler/vendor_gems.rb.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ GIT
66

77
GIT
88
remote: https://github.com/jhawthorn/pub_grub.git
9-
revision: 55a2d65c5c3176f72de5e25d59fb6f52b9fe60ef
9+
revision: 57d4f344366c8b86f7fe506e9bfa08f3c731e397
10+
ref: 57d4f344366c8b86f7fe506e9bfa08f3c731e397
1011
specs:
1112
pub_grub (0.5.0)
1213

0 commit comments

Comments
 (0)