summaryrefslogtreecommitdiff
path: root/lib/bundler/resolver.rb
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2017-09-10 20:02:57 +0000
committerThe Bundler Bot <bot@bundler.io>2017-09-10 20:02:57 +0000
commit3abe35c810183a389934ab8e68f7a890cde0b44f (patch)
treea4ac5575c2f76f04ac696642b511d63beee70deb /lib/bundler/resolver.rb
parent406cdc44bcafd0d89820da0c3b039d08b31db67e (diff)
parent3cc7b11af7accc74cfa631f7a1e51c2d75e801c4 (diff)
downloadbundler-3abe35c810183a389934ab8e68f7a890cde0b44f.tar.gz
Auto merge of #6014 - greysteil:failing-pre-release-spec, r=segiddins
Add spec that pre-release versions aren't selected when not in the Gemfile ### What was the end-user problem that led to this PR? The problem was that a pre-release version was being installed when the user hadn't asked for one, and a non-prerelease install was possible. ### What was your diagnosis of the problem? My diagnosis was that this was caused by the change to the way pre-releases get selected for resolution when we moved to Molinillo 0.6.0. See the change to `lib/bundler/index.rb` in https://github.com/bundler/bundler/pull/5902. ### What is your fix for the problem, implemented in this PR? My fix... isn't present yet. Basically we want to replicate the `wants_prerelease || only_prerelease` behaviour in `Bundler::Resolver#requirement_satisfied_by?`, but it's late and I haven't thought about how to do that yet. Instead, here's a failing spec. ### Why did you choose this fix out of the possible options? I chose this fix because it's late and I haven't thought about how to fix this yet, but I at least wanted it flagged.
Diffstat (limited to 'lib/bundler/resolver.rb')
-rw-r--r--lib/bundler/resolver.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index 78152d71cd..7962ff40f8 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -42,6 +42,9 @@ module Bundler
end
def start(requirements)
+ @prerelease_specified = {}
+ requirements.each {|dep| @prerelease_specified[dep.name] ||= dep.prerelease? }
+
verify_gemfile_dependencies_are_found!(requirements)
dg = @resolver.resolve(requirements, @base_dg)
dg.
@@ -103,6 +106,14 @@ module Bundler
search = @search_for[dependency] ||= begin
index = index_for(dependency)
results = index.search(dependency, @base[dependency.name])
+
+ unless @prerelease_specified[dependency.name]
+ # Move prereleases to the beginning of the list, so they're considered
+ # last during resolution.
+ pre, results = results.partition {|spec| spec.version.prerelease? }
+ results = pre + results
+ end
+
if vertex = @base_dg.vertex_named(dependency.name)
locked_requirement = vertex.payload.requirement
end