diff options
author | Aleksey Lim <alsroot@member.fsf.org> | 2010-08-14 04:30:14 +0800 |
---|---|---|
committer | Puppet Labs, Inc. <github@reductivelabs.com> | 2010-08-14 04:41:08 +0800 |
commit | e984b0810eeeeebe7092cda5eba1310fa928ca5c (patch) | |
tree | beb9a68b91ce994a9508d647cca6cc678080a16b /lib/puppet/provider/vcsrepo | |
parent | 295b3cb16dbcd8e2575d0fef8aef756889e13c66 (diff) | |
download | puppet-vcsrepo-e984b0810eeeeebe7092cda5eba1310fa928ca5c.tar.gz puppet-vcsrepo-e984b0810eeeeebe7092cda5eba1310fa928ca5c.tar.bz2 |
Support latest value for ensure property in git provider
Diffstat (limited to 'lib/puppet/provider/vcsrepo')
-rw-r--r-- | lib/puppet/provider/vcsrepo/git.rb | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index a17990e..7ae9182 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -30,18 +30,19 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) FileUtils.rm_rf(@resource.value(:path)) end - def revision - if !working_copy_exists? - create + def latest? + at_path do + return self.revision == self.latest end + end - current = at_path { git('rev-parse', 'HEAD') } - canonical = at_path { git('rev-parse', @resource.value(:revision)) } - if current == canonical - @resource.value(:revision) - else - current - end + def latest + fetch + return get_revision('origin/HEAD') + end + + def revision + return get_revision('HEAD') end def revision=(desired) @@ -219,4 +220,17 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) at_path { git('branch', '-a') }.gsub('*', ' ').split(/\n/).map { |line| line.strip } end + def get_revision(rev) + if !working_copy_exists? + create + end + + current = at_path { git('rev-parse', rev).strip } + if @resource.value(:revision) + canonical = at_path { git('rev-parse', @resource.value(:revision)).strip } + current = @resource.value(:revision) if current == canonical + end + + return current + end end |