From 2513bd223de3716c2c8911b41c1f9461c7af7e97 Mon Sep 17 00:00:00 2001 From: Agis Anastasopoulos Date: Thu, 14 Jan 2016 07:36:23 +0200 Subject: Uncolored output in GitProxy#branch Fixes #4056. --- lib/bundler/source/git/git_proxy.rb | 2 +- spec/install/gemfile/git_spec.rb | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index edf7924f5f..a9f782e8d6 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -64,7 +64,7 @@ module Bundler def branch @branch ||= allowed_in_path do - git("branch") =~ /^\* (.*)$/ && $1.strip + git("rev-parse --abbrev-ref HEAD").strip end end diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index ad1e7736da..ba7e439066 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -996,4 +996,29 @@ describe "bundle install with git sources" do expect(exitstatus).to be_zero if exitstatus end end + + describe "when the git source is overriden with a local git repo" do + before do + bundle "config --global local.foo #{lib_path("foo")}" + end + + describe "and git output is colorized" do + before do + File.open("#{ENV["HOME"]}/.gitconfig", "w") do |f| + f.write("[color]\n\tui = always\n") + end + end + + it "installs successfully" do + build_git "foo", "1.0", :path => lib_path("foo") + + gemfile <<-G + gem "foo", :git => "#{lib_path("foo")}", :branch => "master" + G + + bundle :install + should_be_installed "foo 1.0" + end + end + end end -- cgit v1.2.1