summaryrefslogtreecommitdiff
path: root/lib/puppet/provider/vcsrepo
diff options
context:
space:
mode:
authorPieter van de Bruggen <pvande@gmail.com>2012-01-19 16:39:21 -0800
committerPieter van de Bruggen <pvande@gmail.com>2012-01-19 16:39:21 -0800
commitb3de3a5c2b23cef308b6d814a08b4e2a3ab6e791 (patch)
treea3a7c5e50adf99757c59954cb23af7b6f761fb90 /lib/puppet/provider/vcsrepo
parentc3dabc322b33ed8dc3acc2dcfe05d58a3c21424b (diff)
parentb931190b329979cd59b1ca721152ed0430296d0a (diff)
Merge pull request #17 from mmrobins/ticket/master/11798_fix_sha1_revision
(#11798) Fix git checkout of revisions
Diffstat (limited to 'lib/puppet/provider/vcsrepo')
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb
index 6cbda67..7fa755d 100644
--- a/lib/puppet/provider/vcsrepo/git.rb
+++ b/lib/puppet/provider/vcsrepo/git.rb
@@ -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