summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2010-07-29 09:47:53 +1000
committerJames Turnbull <james@lovedthanlost.net>2010-07-29 09:47:53 +1000
commit295b3cb16dbcd8e2575d0fef8aef756889e13c66 (patch)
tree687087df9d4d56c4168dc4bbb38ec9c1733bb780
parent12e35e04d8df95a97db000c5c77c45599270bd0a (diff)
Git provider fails to create a repo if it does not exist
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb
index 6395590..a17990e 100644
--- a/lib/puppet/provider/vcsrepo/git.rb
+++ b/lib/puppet/provider/vcsrepo/git.rb
@@ -3,6 +3,7 @@ require File.join(File.dirname(__FILE__), '..', 'vcsrepo')
Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) do
desc "Supports Git repositories"
+ ##TODO modify the commands below so that the su - is included
commands :git => 'git'
defaultfor :git => :exists
has_features :bare_repositories, :reference_tracking
@@ -30,8 +31,10 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
end
def revision
- fetch
- update_references
+ if !working_copy_exists?
+ create
+ end
+
current = at_path { git('rev-parse', 'HEAD') }
canonical = at_path { git('rev-parse', @resource.value(:revision)) }
if current == canonical
@@ -43,7 +46,6 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
def revision=(desired)
fetch
- update_references
if local_branch_revision?(desired)
at_path do
git('checkout', desired)
@@ -98,8 +100,12 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
if @resource.value(:ensure) == :bare
args << '--bare'
end
- args.push(source, path)
- git(*args)
+ if !File.exist?(File.join(@resource.value(:path), '.git'))
+ args.push(source, path)
+ git(*args)
+ else
+ notice "Repo has already been cloned"
+ end
end
def fetch