git: correct checking out latest revision of a branch.

This commit is contained in:
Brett Lentz 2010-09-14 11:24:14 -07:00
parent 81787d4940
commit 21faae5015
1 changed files with 10 additions and 1 deletions

View File

@ -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