summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAaron Stone <aaron@serendipity.cx>2013-09-04 11:15:02 -0700
committerAaron Stone <aaron@serendipity.cx>2013-09-04 11:15:02 -0700
commit0eeb6501b1b2ea84c38b0d4464ac42c12c4e9fa7 (patch)
treec26854c256da1f671dae965bb37600ac1c605aed /lib
parentf49f3fe075c1b0fbb905f09066ae17cebc51cc83 (diff)
parente69c6eac89fbbbd5c459388eef30b1320ab9d826 (diff)
downloadpuppet-vcsrepo-0eeb6501b1b2ea84c38b0d4464ac42c12c4e9fa7.tar.gz
puppet-vcsrepo-0eeb6501b1b2ea84c38b0d4464ac42c12c4e9fa7.tar.bz2
Merge pull request #91 from jiacona/master
update git provider to handle checking out into an existing (empty) dir
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/provider/vcsrepo.rb8
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb2
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/puppet/provider/vcsrepo.rb b/lib/puppet/provider/vcsrepo.rb
index 2c026ba..8793e63 100644
--- a/lib/puppet/provider/vcsrepo.rb
+++ b/lib/puppet/provider/vcsrepo.rb
@@ -17,6 +17,14 @@ class Puppet::Provider::Vcsrepo < Puppet::Provider
File.directory?(@resource.value(:path))
end
+ def path_empty?
+ # Path is empty if the only entries are '.' and '..'
+ d = Dir.new(@resource.value(:path))
+ d.read # should return '.'
+ d.read # should return '..'
+ d.read.nil?
+ end
+
# Note: We don't rely on Dir.chdir's behavior of automatically returning the
# value of the last statement -- for easier stubbing.
def at_path(&block) #:nodoc:
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb
index 58330f6..47e84d2 100644
--- a/lib/puppet/provider/vcsrepo/git.rb
+++ b/lib/puppet/provider/vcsrepo/git.rb
@@ -147,7 +147,7 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo)
end
def check_force
- if path_exists?
+ if path_exists? and not path_empty?
if @resource.value(:force)
notice "Removing %s to replace with vcsrepo." % @resource.value(:path)
destroy