summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaden Lovelace <caden@herostrat.us>2015-06-22 23:23:46 +0100
committerAndre Arko <andre@arko.net>2015-08-19 00:32:35 -0700
commit58e0f1d203851411a83a1b0fbf034d903ddaf024 (patch)
treea82432ab56cafcf5cc7f9de56d2e8c53a43692d0
parent3d00ce964e01314db855b979cd253b15e658d423 (diff)
downloadbundler-58e0f1d203851411a83a1b0fbf034d903ddaf024.tar.gz
Add ability to update gems via source for backwards-compatibility.
See comments.
-rw-r--r--lib/bundler/definition.rb5
-rw-r--r--spec/commands/update_spec.rb77
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