diff options
Diffstat (limited to 'lib/puppet/provider')
-rw-r--r-- | lib/puppet/provider/vcsrepo/git.rb | 20 | ||||
-rw-r--r-- | lib/puppet/provider/vcsrepo/svn.rb | 6 |
2 files changed, 16 insertions, 10 deletions
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 442ea61..c96095b 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -6,7 +6,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) ##TODO modify the commands below so that the su - is included optional_commands :git => 'git', :su => 'su' - has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user + has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user, :depth def create if !@resource.value(:source) @@ -39,12 +39,10 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) def latest branch = on_branch? - if branch == 'master' - return get_revision("#{@resource.value(:remote)}/HEAD") - elsif branch == '(no branch)' + if !branch return get_revision('HEAD') else - return get_revision("#{@resource.value(:remote)}/%s" % branch) + return get_revision("#{@resource.value(:remote)}/#{branch}") end end @@ -107,10 +105,10 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) end def update_remote_origin_url - current = git_with_identity('config', 'remote.origin.url') + current = git_with_identity('config', "remote.#{@resource.value(:remote)}.url") unless @resource.value(:source).nil? if current.nil? or current.strip != @resource.value(:source) - git_with_identity('config', 'remote.origin.url', @resource.value(:source)) + git_with_identity('config', "remote.#{@resource.value(:remote)}.url", @resource.value(:source)) end end end @@ -133,9 +131,15 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) def clone_repository(source, path) check_force args = ['clone'] + if @resource.value(:depth) and @resource.value(:depth).to_i > 0 + args.push('--depth', @resource.value(:depth).to_s) + end if @resource.value(:ensure) == :bare args << '--bare' end + if @resource.value(:remote) != 'origin' + args.push('--origin', @resource.value(:remote)) + end if !File.exist?(File.join(@resource.value(:path), '.git')) args.push(source, path) Dir.chdir("/") do @@ -255,7 +259,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) end def on_branch? - at_path { git_with_identity('branch', '-a') }.split(/\n/).grep(/\*/).first.to_s.gsub('*', '').strip + at_path { git_with_identity('rev-parse', '--abbrev-ref', 'HEAD').chomp } end def tags diff --git a/lib/puppet/provider/vcsrepo/svn.rb b/lib/puppet/provider/vcsrepo/svn.rb index e0d5b21..7856acd 100644 --- a/lib/puppet/provider/vcsrepo/svn.rb +++ b/lib/puppet/provider/vcsrepo/svn.rb @@ -24,8 +24,10 @@ Puppet::Type.type(:vcsrepo).provide(:svn, :parent => Puppet::Provider::Vcsrepo) if File.directory?(@resource.value(:path)) # :path is an svn checkout return true if File.directory?(File.join(@resource.value(:path), '.svn')) - # :path is an svn server - return true if svnlook('uuid', @resource.value(:path)) + if File.directory?(File.join(@resource.value(:path), 'format')) + # :path is an svn server + return true if svnlook('uuid', @resource.value(:path)) + end end false end |