diff options
-rw-r--r-- | lib/bundler/definition.rb | 5 | ||||
-rw-r--r-- | spec/commands/update_spec.rb | 77 |
2 files changed, 82 insertions, 0 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index f53579fc52..a6e124eddb 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -557,6 +557,11 @@ module Bundler # 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.source.name) + + # XXX This is a backwards-compatibility fix to preserve the ability to + # unlock a single gem by passing its name via `--source`. See issue #3759 + 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. diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb index d6d9a3bccc..61054f6ffd 100644 --- a/spec/commands/update_spec.rb +++ b/spec/commands/update_spec.rb @@ -132,6 +132,8 @@ describe "bundle update" do describe "with --source option" do it "should not update gems outwith the source that happen to have the same name" do + pending("Allowed to fail to preserve backwards-compatibility") + install_gemfile <<-G source "file://#{gem_repo2}" gem "activesupport" @@ -141,6 +143,81 @@ describe "bundle update" do bundle "update --source activesupport" should_not_be_installed "activesupport 3.0" end + + it "should update gems outwith the source that happen to have the same name" do + install_gemfile <<-G + source "file://#{gem_repo2}" + gem "activesupport" + G + update_repo2 { build_gem "activesupport", "3.0" } + + bundle "update --source activesupport" + should_be_installed "activesupport 3.0" + end + end + + context "when there is a child dependency that is also in the gemfile" do + before do + build_repo2 do + build_gem "fred", "1.0" + build_gem "harry" , "1.0" do |s| + s.add_dependency "fred" + end + end + + install_gemfile <<-G + source "file://#{gem_repo2}" + gem "harry" + gem "fred" + G + end + + it "should not update the child dependencies of a gem that has the same name as the source" do + update_repo2 do + build_gem "fred", "2.0" + build_gem "harry", "2.0" do |s| + s.add_dependency "fred" + end + end + + bundle "update --source harry" + should_be_installed "harry 2.0" + should_be_installed "fred 1.0" + end + end + + context "when there is a child dependency that appears elsewhere in the dependency graph" do + before do + build_repo2 do + build_gem "fred", "1.0" do |s| + s.add_dependency "george" + end + build_gem "george", "1.0" + build_gem "harry" , "1.0" do |s| + s.add_dependency "george" + end + end + + install_gemfile <<-G + source "file://#{gem_repo2}" + gem "harry" + gem "fred" + G + end + + it "should not update the child dependencies of a gem that has the same name as the source" do + update_repo2 do + build_gem "george", "2.0" + build_gem "harry", "2.0" do |s| + s.add_dependency "george" + end + end + + bundle "update --source harry" + should_be_installed "harry 2.0" + should_be_installed "fred 1.0" + should_be_installed "george 1.0" + end end end |