summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-06-06 13:53:29 +0900
committerHomu <homu@barosl.com>2016-06-06 13:53:29 +0900
commit117b98246e4c442a3899fbfe52949cfd5112c8d9 (patch)
tree0036a529470ccb73ad53e74d7cf3c38644c5fb86
parent1c48ad2d1b77e470d1127c6494c68fdf1b129031 (diff)
parent2d4e852b395b6972ff41be9f899fd7911866ca44 (diff)
downloadbundler-117b98246e4c442a3899fbfe52949cfd5112c8d9.tar.gz
Auto merge of #4617 - allenzhao:path-development, r=RochesterinNYC
Add logic to check if the issue is path source related Close #2175 **Todo:** - [x] Add spec test (Ref #2183)
-rw-r--r--lib/bundler/definition.rb30
-rw-r--r--lib/bundler/source/path.rb4
-rw-r--r--spec/install/deploy_spec.rb28
3 files changed, 54 insertions, 8 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 413eedc168..366b51b4a7 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -366,10 +366,20 @@ module Bundler
changed = []
gemfile_sources = sources.lock_sources
- if @locked_sources != gemfile_sources
- new_sources = gemfile_sources - @locked_sources
- deleted_sources = @locked_sources - gemfile_sources
+ new_sources = gemfile_sources - @locked_sources
+ deleted_sources = @locked_sources - gemfile_sources
+
+ new_deps = @dependencies - @locked_deps
+ 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.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
if new_sources.any?
added.concat new_sources.map {|source| "* source: #{source}" }
end
@@ -379,11 +389,7 @@ module Bundler
end
end
- new_deps = @dependencies - @locked_deps
- deleted_deps = @locked_deps - @dependencies
-
added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
-
if deleted_deps.any?
deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" }
end
@@ -542,7 +548,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 569cea00f8..2147f2fdc3 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