summaryrefslogtreecommitdiff
path: root/lib/puppet/provider/vcsrepo
diff options
context:
space:
mode:
authorAaron Stone <aaron@serendipity.cx>2013-07-17 13:43:24 -0700
committerAaron Stone <aaron@serendipity.cx>2013-07-17 13:43:24 -0700
commit76227ed83795b882e0d8cffcff79ea5bab61ab6c (patch)
tree230c70ee66a8d47641ab7f416b1150db26e717e0 /lib/puppet/provider/vcsrepo
parentc0042a9a69f1ca58cc41e5e0efcc9afda687ed24 (diff)
parent8a58caef1fe6b2c301f321cd0d52e42cc58f5f6b (diff)
downloadpuppet-vcsrepo-76227ed83795b882e0d8cffcff79ea5bab61ab6c.tar.gz
puppet-vcsrepo-76227ed83795b882e0d8cffcff79ea5bab61ab6c.tar.bz2
Merge pull request #78 from jhoblitt/git_provider_checkout_remote_refs
fix git provider checkout of a remote ref on an existing repo
Diffstat (limited to 'lib/puppet/provider/vcsrepo')
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb
index c298179..536f652 100644
--- a/lib/puppet/provider/vcsrepo/git.rb
+++ b/lib/puppet/provider/vcsrepo/git.rb
@@ -56,7 +56,20 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
if tag_revision?(@resource.value(:revision))
canonical = at_path { git_with_identity('show', @resource.value(:revision)).scan(/^commit (.*)/).to_s }
else
- canonical = at_path { git_with_identity('rev-parse', @resource.value(:revision)).chomp }
+ # if it's not a tag, look for it as a local ref
+ canonical = at_path { git_with_identity('rev-parse', '--revs-only', @resource.value(:revision)).chomp }
+ if canonical.empty?
+ # git rev-parse executed properly but didn't find the ref;
+ # look for it in the remote
+ remote_ref = at_path { git_with_identity('ls-remote', '--heads', '--tags', @resource.value(:remote), @resource.value(:revision)).chomp }
+ if remote_ref.empty?
+ fail("#{@resource.value(:revision)} is not a local or remote ref")
+ end
+
+ # $ git ls-remote --heads --tags origin feature/cvs
+ # 7d4244b35e72904e30130cad6d2258f901c16f1a refs/heads/feature/cvs
+ canonical = remote_ref.split.first
+ end
end
if current == canonical