Merge pull request #3 from ody/bug/master/7797
Makes git tags actually work as a revision option.
This commit is contained in:
@@ -41,15 +41,22 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
|
|||||||
branch = on_branch?
|
branch = on_branch?
|
||||||
if branch == 'master'
|
if branch == 'master'
|
||||||
return get_revision('origin/HEAD')
|
return get_revision('origin/HEAD')
|
||||||
|
elsif branch == '(no branch)'
|
||||||
|
return get_revision('HEAD')
|
||||||
else
|
else
|
||||||
return get_revision('origin/%s' % branch)
|
return get_revision('origin/%s' % branch)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def revision
|
def revision
|
||||||
update_references
|
update_references
|
||||||
current = at_path { git('rev-parse', 'HEAD') }
|
current = at_path { git('rev-parse', 'HEAD').chomp }
|
||||||
canonical = at_path { git('rev-parse', @resource.value(:revision)) }
|
if tag_revision?(@resource.value(:revision))
|
||||||
|
canonical = at_path { git('show', @resource.value(:revision)).scan(/commit (.*)/).to_s }
|
||||||
|
else
|
||||||
|
canonical = at_path { git('rev-parse', @resource.value(:revision)).chomp }
|
||||||
|
end
|
||||||
|
|
||||||
if current == canonical
|
if current == canonical
|
||||||
@resource.value(:revision)
|
@resource.value(:revision)
|
||||||
else
|
else
|
||||||
@@ -182,7 +189,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
|
|||||||
if local_branch_revision?
|
if local_branch_revision?
|
||||||
reset(revision)
|
reset(revision)
|
||||||
elsif tag_revision?
|
elsif tag_revision?
|
||||||
at_path { git('checkout', '-b', revision) }
|
at_path { git('checkout', revision) }
|
||||||
elsif remote_branch_revision?
|
elsif remote_branch_revision?
|
||||||
at_path { git('checkout', '-b', revision, '--track', "origin/#{revision}") }
|
at_path { git('checkout', '-b', revision, '--track', "origin/#{revision}") }
|
||||||
end
|
end
|
||||||
@@ -206,7 +213,10 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
|
|||||||
def remote_branch_revision?(revision = @resource.value(:revision))
|
def remote_branch_revision?(revision = @resource.value(:revision))
|
||||||
# git < 1.6 returns 'origin/#{revision}'
|
# git < 1.6 returns 'origin/#{revision}'
|
||||||
# git 1.6+ returns 'remotes/origin/#{revision}'
|
# git 1.6+ returns 'remotes/origin/#{revision}'
|
||||||
at_path { branches.grep /(remotes\/)?origin\/#{revision}/ }
|
branch = at_path { branches.grep /(remotes\/)?origin\/#{revision}/ }
|
||||||
|
if branch.length > 0
|
||||||
|
return branch
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def local_branch_revision?(revision = @resource.value(:revision))
|
def local_branch_revision?(revision = @resource.value(:revision))
|
||||||
|
|||||||
Reference in New Issue
Block a user