summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Stone <aaron@serendipity.cx>2013-12-04 21:05:03 -0800
committerAaron Stone <aaron@serendipity.cx>2013-12-04 21:05:03 -0800
commit8356fc9c58b2c821c57dc537ec2c95a72f672a5c (patch)
treee41c230bba51dd8963cc2d0a2238a6bcb1a999a2
parenta96a42e38b6c6d306ef158250658ae5673f383a3 (diff)
parent69b93cefcdcd4a80d241dc71d5e6de90842faf11 (diff)
downloadpuppet-vcsrepo-8356fc9c58b2c821c57dc537ec2c95a72f672a5c.tar.gz
puppet-vcsrepo-8356fc9c58b2c821c57dc537ec2c95a72f672a5c.tar.bz2
Merge pull request #109 from mikegerwitz/master
Bug fix: Git provider on_branch? retains trailing newline
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb6
-rw-r--r--spec/unit/puppet/provider/vcsrepo/git_spec.rb12
2 files changed, 15 insertions, 3 deletions
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb
index 17275c4..d488271 100644
--- a/lib/puppet/provider/vcsrepo/git.rb
+++ b/lib/puppet/provider/vcsrepo/git.rb
@@ -39,10 +39,10 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
def latest
branch = on_branch?
- if branch == ''
+ if !branch
return get_revision('HEAD')
else
- return get_revision("#{@resource.value(:remote)}/%s" % branch)
+ return get_revision("#{@resource.value(:remote)}/#{branch}")
end
end
@@ -253,7 +253,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
end
def on_branch?
- at_path { git_with_identity('rev-parse', '--abbrev-ref', 'HEAD') }
+ at_path { git_with_identity('rev-parse', '--abbrev-ref', 'HEAD').chomp }
end
def tags
diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb
index f3d9dd3..554645b 100644
--- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb
+++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb
@@ -296,6 +296,18 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do
end
end
+ context "retrieving the current revision" do
+ before do
+ expects_chdir
+ provider.expects(:git).with('rev-parse', '--abbrev-ref', 'HEAD').returns("foo\n")
+ end
+
+ it "will strip trailing newlines" do
+ provider.expects(:get_revision).with('origin/foo')
+ provider.latest
+ end
+ end
+
describe 'latest?' do
before do
expects_chdir('/tmp/test')