summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-02-17 17:55:28 -0600
committerSamuel Giddins <segiddins@segiddins.me>2017-02-17 17:55:28 -0600
commitdd50f29ec80cdcbdf86ada0a60d66e5338b5aca9 (patch)
tree75d20d44223123f818cc36ac6f45789bb1f63680 /lib
parent1e1530463d69d3967ab24076de98120be3db8431 (diff)
downloadbundler-dd50f29ec80cdcbdf86ada0a60d66e5338b5aca9.tar.gz
[Resolver] Improve sorting of deps with 0 or 1 possibilityseg-resolver-sorting
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/resolver.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index 98d5e7227f..b8d044e6ef 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -329,6 +329,12 @@ module Bundler
private
+ # returns an integer \in (-\infty, 0]
+ # a number closer to 0 means the dependency is less constraining
+ #
+ # dependencies w/ 0 or 1 possibilities (ignoring version requirements)
+ # are given very negative values, so they _always_ sort first,
+ # before dependencies that are unconstrained
def amount_constrained(dependency)
@amount_constrained ||= {}
@amount_constrained[dependency.name] ||= begin
@@ -336,8 +342,9 @@ module Bundler
dependency.requirement.satisfied_by?(base.first.version) ? 0 : 1
else
all = index_for(dependency).search(dependency.name).size
+
if all <= 1
- all
+ all - 1_000_000
else
search = search_for(dependency).size
search - all