summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Moore <tmoore@incrementalism.net>2014-11-08 11:19:10 +1100
committerTim Moore <tmoore@incrementalism.net>2014-11-08 11:19:10 +1100
commit22ee6b2d582a4f3bedb9f8d81ee0607780f2da40 (patch)
tree541d9183bf562fcc79a4eb4c4271ad291304dbfe
parent3f6c21ba9fd2231a00acfa202fc28d7fa49d5c39 (diff)
parent74b5457a6a87f35cd958686dfbad826c445159d7 (diff)
downloadbundler-22ee6b2d582a4f3bedb9f8d81ee0607780f2da40.tar.gz
Merge pull request #3239 from TimMoore/issue-3224-frozen-source-comparison
Fix comparison of frozen sources.
-rw-r--r--lib/bundler/definition.rb37
-rw-r--r--spec/install/gems/sources_spec.rb1
2 files changed, 17 insertions, 21 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 8e7b4d9d9c..3afb53ba9e 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -298,8 +298,6 @@ module Bundler
end
def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
- changes = false
-
msg = "You are trying to install in deployment mode after changing\n" \
"your Gemfile. Run `bundle install` elsewhere and add the\n" \
"updated Gemfile.lock to version control."
@@ -325,32 +323,29 @@ module Bundler
if deleted_sources.any?
deleted.concat deleted_sources.map { |source| "* source: #{source}" }
end
-
- changes = true
end
- both_sources = Hash.new { |h,k| h[k] = ["no specified source", "no specified source"] }
- @dependencies.each { |d| both_sources[d.name][0] = d.source if d.source }
- @locked_deps.each { |d| both_sources[d.name][1] = d.source if d.source }
- both_sources.delete_if { |k,v| v[0] == v[1] }
+ new_deps = @dependencies - @locked_deps
+ deleted_deps = @locked_deps - @dependencies
- if @dependencies != @locked_deps
- new_deps = @dependencies - @locked_deps
- deleted_deps = @locked_deps - @dependencies
+ if new_deps.any?
+ added.concat new_deps.map { |d| "* #{pretty_dep(d)}" }
+ end
- if new_deps.any?
- added.concat new_deps.map { |d| "* #{pretty_dep(d)}" }
- end
+ if deleted_deps.any?
+ deleted.concat deleted_deps.map { |d| "* #{pretty_dep(d)}" }
+ end
- 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 }
+ @locked_deps.each { |d| both_sources[d.name][1] = d.source }
- both_sources.each do |name, sources|
- changed << "* #{name} from `#{sources[0]}` to `#{sources[1]}`"
+ both_sources.each do |name, (dep, lock_source)|
+ if (dep.nil? && !lock_source.nil?) || (!dep.nil? && !lock_source.nil? && !lock_source.can_lock?(dep))
+ gemfile_source_name = (dep && dep.source) || 'no specified source'
+ lockfile_source_name = lock_source || 'no specified source'
+ changed << "* #{name} from `#{gemfile_source_name}` to `#{lockfile_source_name}`"
end
-
- changes = true
end
msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
diff --git a/spec/install/gems/sources_spec.rb b/spec/install/gems/sources_spec.rb
index 546aac4583..e3ab84c0aa 100644
--- a/spec/install/gems/sources_spec.rb
+++ b/spec/install/gems/sources_spec.rb
@@ -72,6 +72,7 @@ describe "bundle install with gems on multiple sources" do
gemfile <<-G
source "file://#{gem_repo3}"
source "file://#{gem_repo1}" do
+ gem "thin" # comes first to test name sorting
gem "rack"
end
gem "rack-obama" # shoud come from repo3!