summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gerwitz <gerwitzm@lovullo.com>2013-12-02 11:38:56 -0500
committerMike Gerwitz <gerwitzm@lovullo.com>2013-12-02 12:24:04 -0500
commit8837be29ff114228f86d67c59337119120690e44 (patch)
tree624591a7ef2f67b2bee80b05e2357da18fc257c0
parent4689c514a12764933a9cb1e2858343f0ba5923b3 (diff)
downloadpuppet-vcsrepo-8837be29ff114228f86d67c59337119120690e44.tar.gz
puppet-vcsrepo-8837be29ff114228f86d67c59337119120690e44.tar.bz2
Using rev-parse to determine branch name of HEAD for on_branch? method
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb4
-rw-r--r--spec/unit/puppet/provider/vcsrepo/git_spec.rb6
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb
index 6bc1c3d..17275c4 100644
--- a/lib/puppet/provider/vcsrepo/git.rb
+++ b/lib/puppet/provider/vcsrepo/git.rb
@@ -39,7 +39,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
def latest
branch = on_branch?
- if branch == '(no branch)'
+ if branch == ''
return get_revision('HEAD')
else
return get_revision("#{@resource.value(:remote)}/%s" % branch)
@@ -253,7 +253,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
end
def on_branch?
- at_path { git_with_identity('branch', '-a') }.split(/\n/).grep(/\*/).first.to_s.gsub('*', '').strip
+ at_path { git_with_identity('rev-parse', '--abbrev-ref', 'HEAD') }
end
def tags
diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb
index 15fee53..f3d9dd3 100644
--- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb
+++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb
@@ -323,19 +323,19 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do
end
context 'on master' do
it do
- provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a))
+ provider.expects(:git).with('rev-parse', '--abbrev-ref', 'HEAD').returns(fixture(:git_branch_a))
provider.latest.should == 'master'
end
end
context 'no branch' do
it do
- provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_none))
+ provider.expects(:git).with('rev-parse', '--abbrev-ref', 'HEAD').returns(fixture(:git_branch_none))
provider.latest.should == 'master'
end
end
context 'feature/bar' do
it do
- provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_feature_bar))
+ provider.expects(:git).with('rev-parse', '--abbrev-ref', 'HEAD').returns(fixture(:git_branch_feature_bar))
provider.latest.should == 'master'
end
end