summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Zhao <cnallenzhao@gmail.com>2016-05-28 00:24:59 +0800
committerAllen Zhao <cnallenzhao@gmail.com>2016-06-04 13:21:25 +0800
commit2d4e852b395b6972ff41be9f899fd7911866ca44 (patch)
tree586acf08c045d09387035e5187888acb6540a457
parent77f005fb906392620c8b9a143f343f9c9ef0e1cf (diff)
downloadbundler-2d4e852b395b6972ff41be9f899fd7911866ca44.tar.gz
Add spec test and fix logic in definition#converge_dependencies
-rw-r--r--lib/bundler/definition.rb20
-rw-r--r--lib/bundler/source/path.rb4
-rw-r--r--spec/install/deploy_spec.rb28
3 files changed, 47 insertions, 5 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index c0d11c672a..ee40d1acd2 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -366,9 +366,9 @@ module Bundler
deleted_deps = @locked_deps - @dependencies
# Check if it is possible that the source is only changed thing
- if (new_deps.empty? && deleted_deps.empty?) && (new_sources.any? && deleted_sources.any?)
- new_sources.reject! {|source| source.instance_of?(Bundler::Source::Path) && source.path.exist? }
- deleted_sources.reject! {|source| source.instance_of?(Bundler::Source::Path) && source.path.exist? }
+ if (new_deps.empty? && deleted_deps.empty?) && (!new_sources.empty? && !deleted_sources.empty?)
+ new_sources.reject! {|source| source.is_a_path? && source.path.exist? }
+ deleted_sources.reject! {|source| source.is_a_path? && source.path.exist? }
end
if @locked_sources != gemfile_sources
@@ -382,7 +382,9 @@ module Bundler
end
added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
- deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?
+ if deleted_deps.any?
+ deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" }
+ end
both_sources = Hash.new {|h, k| h[k] = [] }
@dependencies.each {|d| both_sources[d.name][0] = d }
@@ -533,7 +535,15 @@ module Bundler
def converge_dependencies
(@dependencies + @locked_deps).each do |dep|
- dep.source = sources.get(dep.source) if dep.source
+ locked_source = @locked_deps.select {|d| d.name == dep.name }.last
+ # This is to make sure that if bundler is installing in deployment mode and
+ # after locked_source and sources don't match, we still use locked_source.
+ if Bundler.settings[:frozen] && !locked_source.nil? &&
+ locked_source.respond_to?(:source) && locked_source.source.instance_of?(Source::Path) && locked_source.source.path.exist?
+ dep.source = locked_source.source
+ elsif dep.source
+ dep.source = sources.get(dep.source)
+ end
end
Set.new(@dependencies) != Set.new(@locked_deps)
end
diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb
index 3ec1e78b97..34cbdde37d 100644
--- a/lib/bundler/source/path.rb
+++ b/lib/bundler/source/path.rb
@@ -107,6 +107,10 @@ module Bundler
name
end
+ def is_a_path?
+ instance_of?(Path)
+ end
+
private
def expanded_path
diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb
index d8e7ff7c08..2156ad8786 100644
--- a/spec/install/deploy_spec.rb
+++ b/spec/install/deploy_spec.rb
@@ -263,4 +263,32 @@ describe "install with --deployment or --frozen" do
should_be_installed "rack 1.0.0"
end
end
+
+ context "with path in Gemfile and packed" do
+ it "works fine after bundle package and bundle install --local" do
+ build_lib "foo", :path => lib_path("foo")
+ install_gemfile <<-G
+ gem "foo", :path => "#{lib_path("foo")}"
+ G
+
+ bundle :install
+ should_be_installed "foo 1.0"
+ bundle "package --all"
+ expect(bundled_app("vendor/cache/foo")).to be_directory
+
+ bundle "install --local"
+ expect(out).to include("Using foo 1.0 from source at")
+ expect(out).to include("vendor/cache/foo")
+ expect(exitstatus).to eq(0) if exitstatus
+
+ simulate_new_machine
+ bundle "install --deployment"
+ expect(out).not_to include("You are trying to install in deployment mode after changing your Gemfile")
+ expect(out).not_to include("You have added to the Gemfile")
+ expect(out).not_to include("You have deleted from the Gemfile")
+ expect(out).to include("Using foo 1.0 from source at")
+ expect(out).to include("vendor/cache/foo")
+ should_be_installed "foo 1.0"
+ end
+ end
end