From f69931f12d20a089caba6574d9a9224f8092d2a0 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Sat, 3 Apr 2010 01:08:12 -0700 Subject: [PATCH] Don't print git gem shas twice during bundle show --- lib/bundler/rubygems_ext.rb | 4 ++-- spec/other/show_spec.rb | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index 6174646f73e..f93c5ccc46b 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -19,9 +19,9 @@ def groups def git_version if @loaded_from && File.exist?(File.join(full_gem_path, ".git")) - rev = Dir.chdir(full_gem_path){ `git rev-parse HEAD`.strip } + sha = Dir.chdir(full_gem_path){ `git rev-parse HEAD`.strip } branch = full_gem_path.split("-")[3] - branch ? " #{branch}-#{rev[0...6]}" : " #{rev[0...6]}" + (branch && branch != sha) ? " #{branch}-#{sha[0...6]}" : " #{sha[0...6]}" end end diff --git a/spec/other/show_spec.rb b/spec/other/show_spec.rb index d48b7dca747..2c2936f365d 100644 --- a/spec/other/show_spec.rb +++ b/spec/other/show_spec.rb @@ -65,4 +65,14 @@ bundle :show out.should include("foo (1.0 omg-#{@revision}") end + + it "doesn't print the branch when tied to a ref" do + sha = revision_for(lib_path("foo-1.0")) + install_gemfile <<-G + gem "foo", :git => "#{lib_path('foo-1.0')}", :ref => "#{sha}" + G + + bundle :show + out.should include("foo (1.0 #{sha[0...6]})") + end end \ No newline at end of file