diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-01-01 12:55:39 -0600 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-01-04 18:11:42 -0600 |
commit | 10695f68c42d9c4de7dd52cbe7781701a30a873c (patch) | |
tree | 7de12f9880d3c76d23b78d13bae9736dfe84a9ca | |
parent | 513546978ab741fcba527bcc428425dce76b1e74 (diff) | |
download | bundler-10695f68c42d9c4de7dd52cbe7781701a30a873c.tar.gz |
[GitProxy] Support branches containing shell metacharacters
-rw-r--r-- | lib/bundler/source/git/git_proxy.rb | 2 | ||||
-rw-r--r-- | spec/install/gemfile/git_spec.rb | 31 | ||||
-rw-r--r-- | spec/support/builders.rb | 8 |
3 files changed, 36 insertions, 5 deletions
diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index c44f00d7b1..4000cc4a4f 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -180,7 +180,7 @@ module Bundler def find_local_revision allowed_in_path do - git("rev-parse --verify #{ref}", true).strip + git("rev-parse --verify '#{ref}'", true).strip end end diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index 85a7693b5a..3d18d2001d 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -209,6 +209,37 @@ describe "bundle install with git sources" do end end + describe "when specifying a branch" do + let(:branch) { "branch" } + let(:repo) { build_git("foo").path } + before(:each) do + update_git("foo", :path => repo, :branch => branch) + end + + it "works" do + install_gemfile <<-G + git "#{repo}", :branch => #{branch.dump} do + gem "foo" + end + G + + expect(the_bundle).to include_gems("foo 1.0") + end + + context "when the branch starts with a `#`" do + let(:branch) { "#149/redirect-url-fragment" } + it "works" do + install_gemfile <<-G + git "#{repo}", :branch => #{branch.dump} do + gem "foo" + end + G + + expect(the_bundle).to include_gems("foo 1.0") + end + end + end + describe "when specifying local override" do it "uses the local repository instead of checking a new one out" do # We don't generate it because we actually don't need it diff --git a/spec/support/builders.rb b/spec/support/builders.rb index 0b660f12f5..55a7c9f7df 100644 --- a/spec/support/builders.rb +++ b/spec/support/builders.rb @@ -665,13 +665,13 @@ module Spec if branch = options[:branch] raise "You can't specify `master` as the branch" if branch == "master" - if `git branch | grep #{branch}`.empty? - silently("git branch #{branch}") + if `git branch | grep '#{branch}'`.empty? + silently("git branch '#{branch}'") end - silently("git checkout #{branch}") + silently("git checkout '#{branch}'") elsif tag = options[:tag] - `git tag #{tag}` + `git tag '#{tag}'` elsif options[:remote] silently("git remote add origin file://#{options[:remote]}") elsif options[:push] |