From f69931f12d20a089caba6574d9a9224f8092d2a0 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Sat, 3 Apr 2010 01:08:12 -0700 Subject: 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 6174646f73..f93c5ccc46 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -19,9 +19,9 @@ module Gem 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 d48b7dca74..2c2936f365 100644 --- a/spec/other/show_spec.rb +++ b/spec/other/show_spec.rb @@ -65,4 +65,14 @@ describe "bundle show with a git repo" do 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 -- cgit v1.2.1