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

Commit

Permalink
Show command now outputs branch names other than master. Closes 239.
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed Apr 2, 2010
1 parent b4958b5 commit bba572b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
9 changes: 4 additions & 5 deletions lib/bundler/rubygems_ext.rb
Expand Up @@ -18,11 +18,10 @@ def groups
end

def git_version
Dir.chdir(full_gem_path) do
rev = `git rev-parse HEAD`.strip[0...6]
branch = `git show-branch --no-color 2>/dev/null`.strip[/\[(.*?)\]/, 1]
branch.empty? ? " #{rev}" : " #{branch}-#{rev}"
end if File.exist?(File.join(full_gem_path, ".git"))
if File.exist?(File.join(full_gem_path, ".git"))
rev, branch = full_gem_path.split("-")[2..-1]
branch ? " #{branch}-#{rev[0...6]}" : " #{rev[0...6]}"
end
end

def to_gemfile(path = nil)
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/specification.rb
Expand Up @@ -16,7 +16,7 @@ def loaded_from
end

def full_gem_path
Pathname.new(loaded_from).dirname.expand_path
Pathname.new(loaded_from).dirname.expand_path.to_s
end

end
Expand Down
28 changes: 28 additions & 0 deletions spec/other/show_spec.rb
Expand Up @@ -34,4 +34,32 @@
end
end

end

describe "bundle show with a git repo" do
before :each do
build_git "foo", "1.0"
update_git "foo", :branch => "omg" do |s|
s.write "lib/foo.rb", "FOO = '1.0.omg'"
end
update_git "foo" # switch back to master branch
end

it "prints out git info" do
install_gemfile <<-G
gem "foo", :git => "#{lib_path('foo-1.0')}"
G
should_be_installed "foo 1.0"
bundle :show
out.should include("foo (1.0 master-")
end

it "prints out branch names other than master" do
install_gemfile <<-G
gem "foo", :git => "#{lib_path('foo-1.0')}", :branch => "omg"
G
should_be_installed "foo 1.0.omg"
bundle :show
out.should include("foo (1.0 omg-")
end
end

0 comments on commit bba572b

Please sign in to comment.