Merge pull request #15 from webfactory/fix_10787
Fix (#10787) - Various fixes/tweaks for the CVS provider
This commit is contained in:
commit
c3dabc322b
@ -13,6 +13,7 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo)
|
|||||||
else
|
else
|
||||||
checkout_repository
|
checkout_repository
|
||||||
end
|
end
|
||||||
|
update_owner
|
||||||
end
|
end
|
||||||
|
|
||||||
def exists?
|
def exists?
|
||||||
@ -32,19 +33,46 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo)
|
|||||||
FileUtils.rm_rf(@resource.value(:path))
|
FileUtils.rm_rf(@resource.value(:path))
|
||||||
end
|
end
|
||||||
|
|
||||||
def revision
|
def latest?
|
||||||
if File.exist?(tag_file)
|
debug "Checking for updates because 'ensure => latest'"
|
||||||
contents = File.read(tag_file)
|
at_path do
|
||||||
# Note: Doesn't differentiate between N and T entries
|
# We cannot use -P to prune empty dirs, otherwise
|
||||||
contents[1..-1]
|
# CVS would report those as "missing", regardless
|
||||||
else
|
# if they have contents or updates.
|
||||||
'MAIN'
|
is_current = (cvs('-nq', 'update', '-d').strip == "")
|
||||||
|
if (!is_current) then debug "There are updates available on the checkout's current branch/tag." end
|
||||||
|
return is_current
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def latest
|
||||||
|
# CVS does not have a conecpt like commit-IDs or change
|
||||||
|
# sets, so we can only have the current branch name (or the
|
||||||
|
# requested one, if that differs) as the "latest" revision.
|
||||||
|
should = @resource.value(:revision)
|
||||||
|
current = self.revision
|
||||||
|
return should != current ? should : current
|
||||||
|
end
|
||||||
|
|
||||||
|
def revision
|
||||||
|
if !@rev
|
||||||
|
if File.exist?(tag_file)
|
||||||
|
contents = File.read(tag_file).strip
|
||||||
|
# Note: Doesn't differentiate between N and T entries
|
||||||
|
@rev = contents[1..-1]
|
||||||
|
else
|
||||||
|
@rev = 'HEAD'
|
||||||
|
end
|
||||||
|
debug "Checkout is on branch/tag '#{@rev}'"
|
||||||
|
end
|
||||||
|
return @rev
|
||||||
|
end
|
||||||
|
|
||||||
def revision=(desired)
|
def revision=(desired)
|
||||||
at_path do
|
at_path do
|
||||||
cvs('update', '-r', desired, '.')
|
cvs('update', '-dr', desired, '.')
|
||||||
|
update_owner
|
||||||
|
@rev = desired
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -61,12 +89,13 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo)
|
|||||||
if @resource.value(:compression)
|
if @resource.value(:compression)
|
||||||
args.push('-z', @resource.value(:compression))
|
args.push('-z', @resource.value(:compression))
|
||||||
end
|
end
|
||||||
args.push('checkout', '-d', basename, module_name)
|
args.push('checkout')
|
||||||
|
if @resource.value(:revision)
|
||||||
|
args.push('-r', @resource.value(:revision))
|
||||||
|
end
|
||||||
|
args.push('-d', basename, module_name)
|
||||||
cvs(*args)
|
cvs(*args)
|
||||||
end
|
end
|
||||||
if @resource.value(:revision)
|
|
||||||
self.revision = @resource.value(:revision)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# When the source:
|
# When the source:
|
||||||
@ -83,4 +112,10 @@ Puppet::Type.type(:vcsrepo).provide(:cvs, :parent => Puppet::Provider::Vcsrepo)
|
|||||||
cvs('-d', path, 'init')
|
cvs('-d', path, 'init')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_owner
|
||||||
|
if @resource.value(:owner) or @resource.value(:group)
|
||||||
|
set_ownership
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user