summaryrefslogtreecommitdiff
path: root/lib/puppet/provider/vcsrepo
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/provider/vcsrepo')
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb
index 888c651..38c247b 100644
--- a/lib/puppet/provider/vcsrepo/git.rb
+++ b/lib/puppet/provider/vcsrepo/git.rb
@@ -38,7 +38,12 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
end
def latest
- return get_revision('origin/HEAD')
+ branch = on_branch?
+ if branch == 'master'
+ return get_revision('origin/HEAD')
+ else
+ return get_revision('origin/%s' % branch)
+ end
end
def revision
@@ -207,6 +212,10 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
at_path { git('branch', '-a') }.gsub('*', ' ').split(/\n/).map { |line| line.strip }
end
+ def on_branch?
+ at_path { git('branch', '-a') }.split(/\n/).grep(/\*/).to_s.gsub('*', '').strip
+ end
+
def tags
at_path { git('tag', '-l') }.split(/\n/).map { |line| line.strip }
end