Merge pull request #17 from mmrobins/ticket/master/11798_fix_sha1_revision

(#11798) Fix git checkout of revisions
This commit is contained in:
Pieter van de Bruggen 2012-01-19 16:39:21 -08:00
commit b3de3a5c2b
1 changed files with 6 additions and 8 deletions

View File

@ -17,7 +17,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
if @resource.value(:ensure) == :bare
notice "Ignoring revision for bare repository"
else
checkout_or_reset
checkout
end
end
if @resource.value(:ensure) != :bare
@ -67,7 +67,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
end
def revision=(desired)
checkout_or_reset(desired)
checkout(desired)
if local_branch_revision?(desired)
# reset instead of pull to avoid merge conflicts. assuming remote is
# authoritative.
@ -188,13 +188,11 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
false
end
def checkout_or_reset(revision = @resource.value(:revision))
if local_branch_revision?
reset(revision)
elsif tag_revision?
at_path { git_with_identity('checkout', revision) }
elsif remote_branch_revision?
def checkout(revision = @resource.value(:revision))
if !local_branch_revision? && remote_branch_revision?
at_path { git_with_identity('checkout', '-b', revision, '--track', "origin/#{revision}") }
else
at_path { git_with_identity('checkout', '--force', revision) }
end
end