summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@plataformatec.com.br>2012-06-14 11:19:52 +0200
committerJosé Valim <jose.valim@plataformatec.com.br>2012-06-14 11:19:52 +0200
commit723330b4bc24f337b5a1ab3271c6b85ccbe4bafd (patch)
tree25c843d983b44792af7e36364f39dad6a1917c15
parent2d4f8ddaccfe6fc460045b93b0c3e44715a94c98 (diff)
downloadbundler-723330b4bc24f337b5a1ab3271c6b85ccbe4bafd.tar.gz
Add config disable_local_branch_check, closes #1985
-rw-r--r--lib/bundler/source.rb8
-rw-r--r--spec/install/git_spec.rb17
2 files changed, 23 insertions, 2 deletions
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index aa05afa535..d9d5dc641b 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -716,6 +716,12 @@ module Bundler
path = Pathname.new(path)
path = path.expand_path(Bundler.root) unless path.relative?
+ unless options["branch"] || Bundler.settings[:disable_local_branch_check]
+ raise GitError, "Cannot use local override for #{name} at #{path} because " \
+ ":branch is not specified in Gemfile. Specify a branch or use " \
+ "`bundle config --delete` to remove the local override"
+ end
+
unless path.exist?
raise GitError, "Cannot use local override for #{name} because #{path} " \
"does not exist. Check `bundle config --delete` to remove the local override"
@@ -727,7 +733,7 @@ module Bundler
# so the Gemfile.lock always picks up the new revision.
@git_proxy = GitProxy.new(path, uri, ref)
- if options["branch"] and git_proxy.branch != options["branch"]
+ if git_proxy.branch != options["branch"] && !Bundler.settings[:disable_local_branch_check]
raise GitError, "Local override for #{name} at #{path} is using branch " \
"#{git_proxy.branch} but Gemfile specifies #{options["branch"]}"
end
diff --git a/spec/install/git_spec.rb b/spec/install/git_spec.rb
index c1c3af54a4..d5baa7c0e6 100644
--- a/spec/install/git_spec.rb
+++ b/spec/install/git_spec.rb
@@ -254,7 +254,7 @@ describe "bundle install with git sources" do
out.should =~ /Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/
end
- it "does not explode if branch is not given" do
+ it "explodes if branch is not given" do
build_git "rack", "0.8"
FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack'))
@@ -265,6 +265,21 @@ describe "bundle install with git sources" do
bundle %|config local.rack #{lib_path('local-rack')}|
bundle :install
+ out.should =~ /cannot use local override/i
+ end
+
+ it "does not explode if disable_local_branch_check is given" do
+ build_git "rack", "0.8"
+ FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack'))
+
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack", :git => "#{lib_path('rack-0.8')}"
+ G
+
+ bundle %|config local.rack #{lib_path('local-rack')}|
+ bundle %|config disable_local_branch_check true|
+ bundle :install
out.should =~ /Your bundle is complete!/
end