1 require File.join(File.dirname(__FILE__), '..', 'vcsrepo')
3 Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) do
4 desc "Supports Subversion repositories"
6 commands :svn => 'svn',
7 :svnadmin => 'svnadmin',
10 has_features :filesystem_types, :reference_tracking, :basic_auth, :configuration, :conflict, :depth
13 if !@resource.value(:source)
14 create_repository(@resource.value(:path))
16 checkout_repository(@resource.value(:source),
17 @resource.value(:path),
18 @resource.value(:revision),
19 @resource.value(:depth))
24 def working_copy_exists?
25 if File.directory?(@resource.value(:path))
26 # :path is an svn checkout
27 return true if File.directory?(File.join(@resource.value(:path), '.svn'))
28 if File.file?(File.join(@resource.value(:path), 'format'))
29 # :path is an svn server
30 return true if svnlook('uuid', @resource.value(:path))
41 FileUtils.rm_rf(@resource.value(:path))
46 (self.revision >= self.latest) and (@resource.value(:source) == self.sourceurl)
51 args = ['--non-interactive']
52 if @resource.value(:basic_auth_username) && @resource.value(:basic_auth_password)
53 args.push('--username', @resource.value(:basic_auth_username))
54 args.push('--password', @resource.value(:basic_auth_password))
55 args.push('--no-auth-cache')
58 if @resource.value(:force)
62 if @resource.value(:configuration)
63 args.push('--config-dir', @resource.value(:configuration))
66 if @resource.value(:trust_server_cert)
67 args.push('--trust-server-cert')
74 args = buildargs.push('info', '-r', 'HEAD')
76 svn(*args)[/^Revision:\s+(\d+)/m, 1]
81 args = buildargs.push('info')
83 svn(*args)[/^URL:\s+(\S+)/m, 1]
88 args = buildargs.push('info')
90 svn(*args)[/^Revision:\s+(\d+)/m, 1]
94 def revision=(desired)
95 args = if @resource.value(:source)
96 buildargs.push('switch', '-r', desired, @resource.value(:source))
98 buildargs.push('update', '-r', desired)
101 if @resource.value(:conflict)
102 args.push('--accept', @resource.value(:conflict))
113 def checkout_repository(source, path, revision, depth)
114 args = buildargs.push('checkout')
116 args.push('-r', revision)
119 args.push('--depth', depth)
121 args.push(source, path)
125 def create_repository(path)
127 if @resource.value(:fstype)
128 args.push('--fs-type', @resource.value(:fstype))
135 if @resource.value(:owner) or @resource.value(:group)