diff options
author | The Bundler Bot <bot@bundler.io> | 2017-09-10 20:02:57 +0000 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-09-18 13:41:56 -0500 |
commit | 050d711ff96706d04a6080fca274c597bc08d211 (patch) | |
tree | 1b7a7f01a7a31934e807c3b5edca7f38b55a62ef | |
parent | 853468cad5cc17823b815cf355fc04026dcb3f8c (diff) | |
download | bundler-050d711ff96706d04a6080fca274c597bc08d211.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.
(cherry picked from commit 3abe35c810183a389934ab8e68f7a890cde0b44f)
-rw-r--r-- | lib/bundler/resolver.rb | 11 | ||||
-rw-r--r-- | spec/resolver/basic_spec.rb | 16 | ||||
-rw-r--r-- | spec/support/indexes.rb | 8 |
3 files changed, 35 insertions, 0 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index 0cf2da007a..348b64ff4e 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -41,6 +41,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.map(&:payload). @@ -99,6 +102,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 diff --git a/spec/resolver/basic_spec.rb b/spec/resolver/basic_spec.rb index 23ff0a8b5d..4db119d6f1 100644 --- a/spec/resolver/basic_spec.rb +++ b/spec/resolver/basic_spec.rb @@ -50,6 +50,22 @@ RSpec.describe "Resolving" do should_resolve_as %w[activemerchant-2.3.5 activesupport-3.0.0.beta1] end + it "doesn't select a pre-release if not specified in the Gemfile" do + dep "activesupport" + dep "reform" + should_resolve_as %w[reform-1.0.0 activesupport-2.3.5] + end + + it "doesn't select a pre-release for sub-dependencies" do + dep "reform" + should_resolve_as %w[reform-1.0.0 activesupport-2.3.5] + end + + it "selects a pre-release for sub-dependencies if it's the only option" do + dep "need-pre" + should_resolve_as %w[need-pre-1.0.0 activesupport-3.0.0.beta1] + end + it "raises an exception if a child dependency is not resolved" do @index = a_unresovable_child_index dep "chef_app_error" diff --git a/spec/support/indexes.rb b/spec/support/indexes.rb index c6d0538063..ba10716114 100644 --- a/spec/support/indexes.rb +++ b/spec/support/indexes.rb @@ -137,6 +137,14 @@ module Spec dep "activesupport", ">= #{version}" end end + + gem "reform", ["1.0.0"] do + dep "activesupport", ">= 1.0.0.beta1" + end + + gem "need-pre", ["1.0.0"] do + dep "activesupport", "~> 3.0.0.beta1" + end end end |