diff options
author | Carl Lerche <carllerche@mac.com> | 2010-08-02 18:21:04 -0700 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-08-02 18:21:18 -0700 |
commit | 37ee7577583215b87e4cfa37ab7bd5a2b1d1722c (patch) | |
tree | 3fd1e2672406d0f93e3fedb5d4d414505a9f6306 | |
parent | 3d7adbeba32a0a123502e8a1e79b20c7616a43ad (diff) | |
download | bundler-37ee7577583215b87e4cfa37ab7bd5a2b1d1722c.tar.gz |
When updating all gems in a git source, also update that source
-rw-r--r-- | lib/bundler/definition.rb | 16 | ||||
-rw-r--r-- | spec/update/git_spec.rb | 21 |
2 files changed, 37 insertions, 0 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 90636cea84..6f5caf4db3 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -310,6 +310,11 @@ module Bundler if in_locked_deps?(dep, locked_dep) || satisfies_locked_spec?(dep) deps << dep elsif dep.source.is_a?(Source::Path) && (!locked_dep || dep.source != locked_dep.source) + @last_resolve.each do |s| + @unlock[:gems] << s.name if s.source == dep.source + end + + dep.source.unlock! if dep.source.respond_to?(:unlock!) dep.source.specs.each { |s| @unlock[:gems] << s.name } end end @@ -340,6 +345,17 @@ module Bundler resolve = SpecSet.new(converged) resolve = resolve.for(expand_dependencies(deps, true), @unlock[:gems]) + diff = @last_resolve.to_a - resolve.to_a + + # Now, we unlock any sources that do not have anymore gems pinned to it + @sources.each do |source| + next unless source.respond_to?(:unlock!) + + unless resolve.any? { |s| s.source == source } + source.unlock! if diff.any? { |s| s.source == source } + end + end + @last_resolve = resolve end diff --git a/spec/update/git_spec.rb b/spec/update/git_spec.rb index 3c1a393156..340bece97d 100644 --- a/spec/update/git_spec.rb +++ b/spec/update/git_spec.rb @@ -35,6 +35,7 @@ describe "bundle update" do out.should include("Using activesupport (3.0) from #{lib_path('rails')} (at master)") should_be_installed "rails 3.0", "activesupport 3.0" end + it "floats on a branch when :branch is used and the source is specified in the update" do build_git "foo", "1.0", :path => lib_path("foo") update_git "foo", :branch => "omg", :path => lib_path("foo") @@ -54,6 +55,26 @@ describe "bundle update" do should_be_installed "foo 1.1" end + it "floats on master when updating all gems that are pinned to the source even if you have child dependencies" do + build_git "foo", :path => lib_path('foo') + build_gem "bar", :to_system => true do |s| + s.add_dependency "foo" + end + + install_gemfile <<-G + gem "foo", :git => "#{lib_path('foo')}" + gem "bar" + G + + update_git "foo", :path => lib_path('foo') do |s| + s.write "lib/foo.rb", "FOO = '1.1'" + end + + bundle "update foo" + + should_be_installed "foo 1.1" + end + it "notices when you change the repo url in the Gemfile" do build_git "foo", :path => lib_path("foo_one") build_git "foo", :path => lib_path("foo_two") |