summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrismo <chrismo@clabs.org>2016-09-13 09:40:21 -0500
committerchrismo <chrismo@clabs.org>2016-09-13 09:40:21 -0500
commit53236466bb1b6dddccee6edb4af8c8b5159e53a1 (patch)
tree6514eeef7750df599f16b846e64ed14851651204
parent1908c7b6338618048363628c1b7408f93879b64b (diff)
downloadbundler-53236466bb1b6dddccee6edb4af8c8b5159e53a1.tar.gz
Fix #4934. Make GVP _after_ eager unlock.
When Definition creates the GemVersionPromoter, it needs to do so _after_ it's performed the eager_unlock so the GVP gets the correct list of unlocked gems. Prior to this fix, it had a stricter list of gems being updated with the new `--patch` or `--minor` options used with `bundle update` and in some cases would have inconsistent results when used without a conservative switch or the `--major` option. See #4934 for details.
-rw-r--r--lib/bundler/definition.rb4
-rw-r--r--spec/bundler/definition_spec.rb69
2 files changed, 70 insertions, 3 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 0cb6e7e399..8bd60168c7 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -102,14 +102,14 @@ module Bundler
end
@unlocking ||= @unlock[:ruby] ||= (!@locked_ruby_version ^ !@ruby_version)
- @gem_version_promoter = create_gem_version_promoter
-
add_current_platform unless Bundler.settings[:frozen]
@path_changes = converge_paths
eager_unlock = expand_dependencies(@unlock[:gems])
@unlock[:gems] = @locked_specs.for(eager_unlock).map(&:name)
+ @gem_version_promoter = create_gem_version_promoter
+
@source_changes = converge_sources
@dependency_changes = converge_dependencies
@local_changes = converge_locals
diff --git a/spec/bundler/definition_spec.rb b/spec/bundler/definition_spec.rb
index c72f50f0d1..71e5bb00aa 100644
--- a/spec/bundler/definition_spec.rb
+++ b/spec/bundler/definition_spec.rb
@@ -137,7 +137,7 @@ describe Bundler::Definition do
describe "initialize" do
context "gem version promoter" do
context "with lockfile" do
- before :each do
+ before do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "foo"
@@ -159,6 +159,73 @@ describe Bundler::Definition do
end
end
+ context "shared dependent gems" do
+ before do
+ build_repo4 do
+ build_gem "isolated_owner", %w(1.0.1 1.0.2) do |s|
+ s.add_dependency "isolated_dep", "~> 2.0"
+ end
+ build_gem "isolated_dep", %w(2.0.1 2.0.2)
+
+ build_gem "shared_owner_a", %w(3.0.1 3.0.2) do |s|
+ s.add_dependency "shared_dep", "~> 5.0"
+ end
+ build_gem "shared_owner_b", %w(4.0.1 4.0.2) do |s|
+ s.add_dependency "shared_dep", "~> 5.0"
+ end
+ build_gem "shared_dep", %w(5.0.1 5.0.2)
+ end
+
+ gemfile <<-G
+ source "file://#{gem_repo4}"
+ gem 'isolated_owner'
+
+ gem 'shared_owner_a'
+ gem 'shared_owner_b'
+ G
+
+ lockfile <<-L
+ GEM
+ remote: file://#{gem_repo4}
+ specs:
+ isolated_dep (2.0.1)
+ isolated_owner (1.0.1)
+ isolated_dep (~> 2.0)
+ shared_dep (5.0.1)
+ shared_owner_a (3.0.1)
+ shared_dep (~> 5.0)
+ shared_owner_b (4.0.1)
+ shared_dep (~> 5.0)
+
+ PLATFORMS
+ ruby
+
+ DEPENDENCIES
+ shared_owner_a
+ shared_owner_b
+ isolated_owner
+
+ BUNDLED WITH
+ 1.13.0
+ L
+ end
+
+ it "should unlock isolated and shared dependencies equally" do
+ # setup for these test costs about 3/4 of a second, much faster to just jam them all in here.
+ # the global before :each defeats any ability to have re-usable setup for many examples in a
+ # single context by wiping out the tmp dir and contents.
+
+ unlock_deps_test(%w(isolated_owner), %w(isolated_dep isolated_owner))
+ unlock_deps_test(%w(isolated_owner shared_owner_a), %w(isolated_dep isolated_owner shared_dep shared_owner_a))
+ end
+
+ def unlock_deps_test(passed_unlocked, expected_calculated)
+ definition = Bundler::Definition.new(bundled_app("Gemfile.lock"), [], Bundler::SourceList.new, :gems => passed_unlocked)
+ unlock_gems = definition.gem_version_promoter.unlock_gems
+ expect(unlock_gems.sort).to eq expected_calculated
+ end
+ end
+
def mock_source_list
Class.new do
def all_sources