diff options
Diffstat (limited to 'lib/puppet/provider')
-rw-r--r-- | lib/puppet/provider/vcsrepo/git.rb | 2 | ||||
-rw-r--r-- | lib/puppet/provider/vcsrepo/svn.rb | 71 |
2 files changed, 71 insertions, 2 deletions
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 298d1dc..7290387 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -42,8 +42,6 @@ Puppet::Type.type(:vcsrepo).provide(:git) do private def clone_repository(source, path) - parent = File.dirname(path) - FileUtils.mkdir_p(parent) git('clone', source, path) end diff --git a/lib/puppet/provider/vcsrepo/svn.rb b/lib/puppet/provider/vcsrepo/svn.rb new file mode 100644 index 0000000..fef7b62 --- /dev/null +++ b/lib/puppet/provider/vcsrepo/svn.rb @@ -0,0 +1,71 @@ +Puppet::Type.type(:vcsrepo).provide(:svn) do + desc "Supports Subversion repositories" + + commands :svn => 'svn', + :svnadmin => 'svnadmin' + + def create + if !@resource.value(:source) + create_repository(@resource.value(:path)) + else + checkout_repository(@resource.value(:source), + @resource.value(:path), + @resource.value(:revision)) + end + end + + def exists? + File.directory?(@resource.value(:path)) + end + + def destroy + FileUtils.rm_rf(@resource.value(:path)) + end + + def revision + at_path do + svn('info')[/^Revision:\s+(\d+)/m, 1] + end + end + + def revision=(desired) + at_path do + svn('update', '-r', desired) + end + end + + private + + def checkout_repository(source, path, revision = nil) + args = ['checkout'] + if revision + args.push('-r', revision) + end + args.push(source, path) + svn(*args) + end + + def create_repository(path) + args = ['create'] + if @resource.value(:fstype) + args.push('--fs-type', @resource.value(:fstype)) + end + args << path + svnadmin(*args) + end + + def reset(desired) + at_path do + git('reset', '--hard', desired) + end + end + + def at_path(&block) + value = nil + Dir.chdir(@resource.value(:path)) do + value = yield + end + value + end + +end |