summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrey Baker <greysteil@gmail.com>2017-11-23 20:53:42 +0000
committerGrey Baker <greysteil@gmail.com>2017-11-27 15:44:24 +0000
commit5e434f754132764465f68e4a2b7dbb8116644d3c (patch)
tree90911c3d675d0092a59fbcbdd3e7af417177565c
parent914a4a8b8d0cf1a79dbc7b334fbb5c2db1ecdc16 (diff)
downloadbundler-5e434f754132764465f68e4a2b7dbb8116644d3c.tar.gz
Resolver: treat dependencies with prerelease versions as slightly constrained
-rw-r--r--lib/bundler/resolver.rb3
-rw-r--r--spec/resolver/basic_spec.rb7
-rw-r--r--spec/support/indexes.rb15
3 files changed, 24 insertions, 1 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index 8a3afa3418..d7911c1de2 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -249,7 +249,8 @@ module Bundler
if all <= 1
all - 1_000_000
else
- search = search_for(dependency).size
+ search = search_for(dependency)
+ search = @prerelease_specified[dependency.name] ? search.count : search.count {|s| !s.version.prerelease? }
search - all
end
end
diff --git a/spec/resolver/basic_spec.rb b/spec/resolver/basic_spec.rb
index 568958ae00..c829243a9f 100644
--- a/spec/resolver/basic_spec.rb
+++ b/spec/resolver/basic_spec.rb
@@ -42,6 +42,13 @@ RSpec.describe "Resolving" do
should_resolve_as %w[a-1.0.0 b-2.0.0 c-1.0.0 d-1.0.0]
end
+ it "prefers non-prerelease resolutions in sort order" do
+ @index = optional_prereleases_index
+ dep "a"
+ dep "b"
+ should_resolve_as %w[a-1.0.0 b-1.5.0]
+ end
+
it "resolves a index with root level conflict on child" do
@index = a_index_with_root_conflict_on_child
dep "i18n", "~> 0.4"
diff --git a/spec/support/indexes.rb b/spec/support/indexes.rb
index 05605195b1..c56d6145a7 100644
--- a/spec/support/indexes.rb
+++ b/spec/support/indexes.rb
@@ -401,5 +401,20 @@ module Spec
gem("d", %w[1.0.0 2.0.0])
end
end
+
+ def optional_prereleases_index
+ build_index do
+ gem("a", %w[1.0.0])
+
+ gem("a", "2.0.0") do
+ dep "b", ">= 2.0.0.pre"
+ end
+
+ gem("b", %w[0.9.0 1.5.0 2.0.0.pre])
+
+ # --- Pre-release support
+ gem "rubygems\0", ["1.3.2"]
+ end
+ end
end
end