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

View File

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