Support latest value for ensure property in git provider
This commit is contained in:
parent
295b3cb16d
commit
e984b0810e
|
@ -30,18 +30,19 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
|
||||||
FileUtils.rm_rf(@resource.value(:path))
|
FileUtils.rm_rf(@resource.value(:path))
|
||||||
end
|
end
|
||||||
|
|
||||||
def revision
|
def latest?
|
||||||
if !working_copy_exists?
|
at_path do
|
||||||
create
|
return self.revision == self.latest
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
current = at_path { git('rev-parse', 'HEAD') }
|
def latest
|
||||||
canonical = at_path { git('rev-parse', @resource.value(:revision)) }
|
fetch
|
||||||
if current == canonical
|
return get_revision('origin/HEAD')
|
||||||
@resource.value(:revision)
|
end
|
||||||
else
|
|
||||||
current
|
def revision
|
||||||
end
|
return get_revision('HEAD')
|
||||||
end
|
end
|
||||||
|
|
||||||
def revision=(desired)
|
def revision=(desired)
|
||||||
|
@ -219,4 +220,17 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
|
||||||
at_path { git('branch', '-a') }.gsub('*', ' ').split(/\n/).map { |line| line.strip }
|
at_path { git('branch', '-a') }.gsub('*', ' ').split(/\n/).map { |line| line.strip }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_revision(rev)
|
||||||
|
if !working_copy_exists?
|
||||||
|
create
|
||||||
|
end
|
||||||
|
|
||||||
|
current = at_path { git('rev-parse', rev).strip }
|
||||||
|
if @resource.value(:revision)
|
||||||
|
canonical = at_path { git('rev-parse', @resource.value(:revision)).strip }
|
||||||
|
current = @resource.value(:revision) if current == canonical
|
||||||
|
end
|
||||||
|
|
||||||
|
return current
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue