Merge remote-tracking branch 'puppetlabs/master' master
authorvarac <varacanero@zeromail.org>
Wed, 28 Sep 2016 09:59:41 +0000 (11:59 +0200)
committervarac <varacanero@zeromail.org>
Wed, 28 Sep 2016 09:59:41 +0000 (11:59 +0200)
lib/puppet/provider/vcsrepo/git.rb

index 804c740..80fa2f0 100644 (file)
@@ -187,9 +187,12 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
 
   private
 
-  # @!visibility private
+  def valid_repo?
+    Dir.chdir(@resource.value(:path)){ system('git rev-parse > /dev/null 2>&1')}
+  end
+
   def bare_git_config_exists?
-    File.exist?(File.join(@resource.value(:path), 'config'))
+    File.exist?(File.join(@resource.value(:path), 'config')) && valid_repo?
   end
 
   # @!visibility private
@@ -227,7 +230,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
   # @!visibility private
   def check_force
     if path_exists? and not path_empty?
-      if @resource.value(:force)
+      if @resource.value(:force) && !valid_repo?
         notice "Removing %s to replace with vcsrepo." % @resource.value(:path)
         destroy
       else