summaryrefslogtreecommitdiff
path: root/lib/bundler/resolver.rb
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-06-30 18:45:10 +0200
committerSamuel Giddins <segiddins@segiddins.me>2017-07-05 14:12:47 +0200
commit0a201f40bc1a8276e529d60812f59a21b0b99138 (patch)
tree1b94ab51acaf17432b784fcfbe482a5d95cea43d /lib/bundler/resolver.rb
parent128e070e181fd617192c2df6a09974f2344f23d4 (diff)
downloadbundler-0a201f40bc1a8276e529d60812f59a21b0b99138.tar.gz
Update specs for the specific platform being added to the lockfile
Also ensure the resolver processes specs in the correct order for error messages
Diffstat (limited to 'lib/bundler/resolver.rb')
-rw-r--r--lib/bundler/resolver.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index 8bdeae275f..39a52b4df8 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -26,6 +26,9 @@ module Bundler
end.min_by(&:size)
trees.reject! {|t| !maximal.include?(t.last) } if maximal
+ trees = trees.sort_by {|t| t.flatten.map(&:to_s) }
+ trees.uniq! {|t| t.flatten.map {|dep| [dep.name, dep.requirement] } }
+
o << trees.sort_by {|t| t.reverse.map(&:name) }.map do |tree|
t = String.new
depth = 2
@@ -379,10 +382,23 @@ module Bundler
amount_constrained(dependency),
conflicts[name] ? 0 : 1,
activated.vertex_named(name).payload ? 0 : search_for(dependency).count,
+ self.class.platform_sort_key(dependency.__platform),
]
end
end
+ # Sort platforms from most general to most specific
+ def self.sort_platforms(platforms)
+ platforms.sort_by do |platform|
+ platform_sort_key(platform)
+ end
+ end
+
+ def self.platform_sort_key(platform)
+ return ["", "", ""] if Gem::Platform::RUBY == platform
+ platform.to_a.map {|part| part || "" }
+ end
+
private
# returns an integer \in (-\infty, 0]
@@ -432,7 +448,7 @@ module Bundler
elsif source = @source_requirements[name]
specs = source.specs[name]
versions_with_platforms = specs.map {|s| [s.version, s.platform] }
- message = String.new("Could not find gem '#{requirement}' in #{source}#{cache_message}.\n")
+ message = String.new("Could not find gem '#{SharedHelpers.pretty_dependency(requirement)}' in #{source}#{cache_message}.\n")
message << if versions_with_platforms.any?
"The source contains '#{name}' at: #{formatted_versions_with_platforms(versions_with_platforms)}"
else