summaryrefslogtreecommitdiff
path: root/lib/puppet/provider/vcsrepo
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2010-09-14 09:02:02 +1000
committerJames Turnbull <james@lovedthanlost.net>2010-09-14 09:02:02 +1000
commitf9f8a808faa0e9d6e83f2c5af880c8080ef9776e (patch)
treeae7fd5f44b8fd34e24cbf3dc43213ea1fa81e1c2 /lib/puppet/provider/vcsrepo
parente572002ab6b9ce15d446ffdab19353d4da18849c (diff)
parenta71777b4ec097954ac58de537685df096d8a8f63 (diff)
downloadpuppet-vcsrepo-f9f8a808faa0e9d6e83f2c5af880c8080ef9776e.tar.gz
puppet-vcsrepo-f9f8a808faa0e9d6e83f2c5af880c8080ef9776e.tar.bz2
Merge branch 'master' of git://github.com/reductivelabs/puppet-vcsrepo
Diffstat (limited to 'lib/puppet/provider/vcsrepo')
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb34
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