Permalink
Browse files

Show command now outputs branch names other than master. Closes 239.

  • Loading branch information...
1 parent b4958b5 commit bba572b5bf15824992b4784ff5f170977a614a93 @indirect indirect committed Apr 2, 2010
Showing with 33 additions and 6 deletions.
  1. +4 −5 lib/bundler/rubygems_ext.rb
  2. +1 −1 lib/bundler/specification.rb
  3. +28 −0 spec/other/show_spec.rb
@@ -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)
@@ -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
View
@@ -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.