diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-07-21 17:14:53 -0700 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-07-21 17:14:53 -0700 |
commit | 19192a31d1eebd89acc767df0389b00640c6e8eb (patch) | |
tree | 7440e8a23bde2d171675e3ec7747e5c342d1cd40 | |
parent | f0a65fea6ba4907a181eae5ede77bc1d74fa7c78 (diff) | |
download | bundler-19192a31d1eebd89acc767df0389b00640c6e8eb.tar.gz |
Unlock Path sources when their dependencies change
-rw-r--r-- | lib/bundler/definition.rb | 21 | ||||
-rw-r--r-- | spec/install/path_spec.rb | 21 |
2 files changed, 41 insertions, 1 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index b47dc62579..b456075663 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -204,9 +204,16 @@ module Bundler end end + # Remove elements from the locked specs that are expired. This will most + # commonly happen if the Gemfile has changed since the lockfile was last + # generated def converge_locked_specs deps = [] + # Build a list of dependencies that are the same in the Gemfile + # and Gemfile.lock. If the Gemfile modified a dependency, but + # the gem in the Gemfile.lock still satisfies it, this is fine + # too. @dependencies.each do |dep| if in_locked_deps?(dep) || satisfies_locked_spec?(dep) deps << dep @@ -217,10 +224,22 @@ module Bundler @last_resolve.each do |s| s.source = @sources.find { |src| s.source == src } + # Don't add a spec to the list if its source is expired. For example, + # if you change a Git gem to Rubygems. next if s.source.nil? || @unlock[:sources].include?(s.name) # If the spec is from a path source and it doesn't exist anymore # then we just unlock it. - next if s.source.instance_of?(Source::Path) && s.source.specs[s].empty? + + # Path sources have special logic + if s.source.instance_of?(Source::Path) + other = s.source.specs[s].first + + # If the spec is no longer in the path source, unlock it. This + # commonly happens if the version changed in the gemspec + next unless other + # If the dependencies of the path source have changed, unlock it + next unless s.dependencies.sort == other.dependencies.sort + end converged << s end diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb index 790166cbbf..d82e2223f0 100644 --- a/spec/install/path_spec.rb +++ b/spec/install/path_spec.rb @@ -261,6 +261,27 @@ describe "bundle install with explicit source paths" do end end + describe "when dependencies in the path are updated" do + before :each do + build_lib "foo", "1.0", :path => lib_path("foo") + + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "foo", :path => "#{lib_path('foo')}" + G + end + + it "gets dependencies that are updated in the path" do + build_lib "foo", "1.0", :path => lib_path("foo") do |s| + s.add_dependency "rack" + end + + bundle "install" + + should_be_installed "rack 1.0.0" + end + end + describe "switching sources" do it "doesn't switch pinned git sources to rubygems when pinning the parent gem to a path source" do build_gem "foo", "1.0", :to_system => true do |s| |