Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Allowing git local override to to accept :branch, :tag or :ref
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-monroe committed Jun 12, 2012
1 parent d748a83 commit 4fde3e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
9 changes: 2 additions & 7 deletions lib/bundler/source.rb
Expand Up @@ -716,9 +716,9 @@ def local_override!(path)
path = Pathname.new(path)
path = path.expand_path(Bundler.root) unless path.relative?

unless options["branch"]
unless options["branch"] || options["tag"] || options["ref"]
raise GitError, "Cannot use local override for #{name} at #{path} because " \
":branch is not specified in Gemfile. Specify a branch or check " \
":branch, :tag, or :ref is not specified in Gemfile. Specify a commit reference or check " \
"`bundle config --delete` to remove the local override"
end

Expand All @@ -733,11 +733,6 @@ def local_override!(path)
# so the Gemfile.lock always picks up the new revision.
@git_proxy = GitProxy.new(path, uri, ref)

if git_proxy.branch != options["branch"]
raise GitError, "Local override for #{name} at #{path} is using branch " \
"#{git_proxy.branch} but Gemfile specifies #{options["branch"]}"
end

changed = cached_revision && cached_revision != git_proxy.revision

if changed && !git_proxy.contains?(cached_revision)
Expand Down
23 changes: 2 additions & 21 deletions spec/install/git_spec.rb
Expand Up @@ -254,7 +254,7 @@
out.should =~ /Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/
end

it "explodes if branch is not given" do
it "explodes if branch, tag, or ref is not given" do
build_git "rack", "0.8"
FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack'))

Expand All @@ -265,26 +265,7 @@

bundle %|config local.rack #{lib_path('local-rack')}|
bundle :install
out.should =~ /because :branch is not specified in Gemfile/
end

it "explodes on different branches" do
build_git "rack", "0.8"

FileUtils.cp_r("#{lib_path('rack-0.8')}/.", lib_path('local-rack'))

update_git "rack", "0.8", :path => lib_path('local-rack'), :branch => "another" do |s|
s.write "lib/rack.rb", "puts :LOCAL"
end

install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack", :git => "#{lib_path('rack-0.8')}", :branch => "master"
G

bundle %|config local.rack #{lib_path('local-rack')}|
bundle :install
out.should =~ /is using branch another but Gemfile specifies master/
out.should =~ /because :branch, :tag, or :ref is not specified in Gemfile/
end

it "explodes on invalid revision" do
Expand Down

0 comments on commit 4fde3e5

Please sign in to comment.