summaryrefslogtreecommitdiff
path: root/lib/puppet/provider/vcsrepo/git.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/provider/vcsrepo/git.rb')
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb20
1 files changed, 12 insertions, 8 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