summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb12
-rw-r--r--lib/puppet/type/vcsrepo.rb7
2 files changed, 16 insertions, 3 deletions
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb
index 000032e..8074950 100644
--- a/lib/puppet/provider/vcsrepo/git.rb
+++ b/lib/puppet/provider/vcsrepo/git.rb
@@ -5,7 +5,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
commands :git => 'git'
- has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user, :depth, :submodules
+ has_features :bare_repositories, :reference_tracking, :ssh_identity, :multiple_remotes, :user, :depth, :branch, :submodules
def create
if @resource.value(:revision) and @resource.value(:ensure) == :bare
@@ -75,7 +75,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
at_path { git_with_identity('reset', '--hard', "#{@resource.value(:remote)}/#{desired}") }
end
#TODO Would this ever reach here if it is bare?
- if @resource.value(:ensure) != :bare
+ if @resource.value(:ensure) != :bare && @resource.value(:submodules) == :true
update_submodules
end
update_owner_and_excludes
@@ -180,6 +180,12 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
args = ['clone']
if @resource.value(:depth) and @resource.value(:depth).to_i > 0
args.push('--depth', @resource.value(:depth).to_s)
+ if @resource.value(:revision)
+ args.push('--branch', @resource.value(:revision).to_s)
+ end
+ end
+ if @resource.value(:branch)
+ args.push('--branch', @resource.value(:branch).to_s)
end
if @resource.value(:ensure) == :bare
args << '--bare'
@@ -415,7 +421,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
# @!visibility private
def git_with_identity(*args)
if @resource.value(:identity)
- Tempfile.open('git-helper') do |f|
+ Tempfile.open('git-helper', Puppet[:statedir]) do |f|
f.puts '#!/bin/sh'
f.puts "exec ssh -oStrictHostKeyChecking=no -oPasswordAuthentication=no -oKbdInteractiveAuthentication=no -oChallengeResponseAuthentication=no -oConnectTimeout=120 -i #{@resource.value(:identity)} $*"
f.close
diff --git a/lib/puppet/type/vcsrepo.rb b/lib/puppet/type/vcsrepo.rb
index 52eace8..e5dfbb5 100644
--- a/lib/puppet/type/vcsrepo.rb
+++ b/lib/puppet/type/vcsrepo.rb
@@ -40,6 +40,9 @@ Puppet::Type.newtype(:vcsrepo) do
feature :depth,
"The provider can do shallow clones"
+ feature :branch,
+ "The name of the branch"
+
feature :p4config,
"The provider understands Perforce Configuration"
@@ -207,6 +210,10 @@ Puppet::Type.newtype(:vcsrepo) do
desc "The value to be used to do a shallow clone."
end
+ newparam :branch, :required_features => [:branch] do
+ desc "The name of the branch to clone."
+ end
+
newparam :p4config, :required_features => [:p4config] do
desc "The Perforce P4CONFIG environment."
end