summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/provider/vcsrepo/git.rb18
-rw-r--r--lib/puppet/provider/vcsrepo/svn.rb4
2 files changed, 13 insertions, 9 deletions
diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb
index 7290387..670d8de 100644
--- a/lib/puppet/provider/vcsrepo/git.rb
+++ b/lib/puppet/provider/vcsrepo/git.rb
@@ -21,12 +21,8 @@ Puppet::Type.type(:vcsrepo).provide(:git) do
end
def revision
- current = Dir.chdir(@resource.value(:path)) do
- git('rev-parse', 'HEAD')
- end
- canonical = Dir.chdir(@resource.value(:path)) do
- git('rev-parse', @resource.value(:revision))
- end
+ current = at_path { git('rev-parse', 'HEAD') }
+ canonical = at_path { git('rev-parse', @resource.value(:revision)) }
if current == canonical
@resource.value(:revision)
else
@@ -64,8 +60,14 @@ Puppet::Type.type(:vcsrepo).provide(:git) do
end
end
- def at_path(&block)
- Dir.chdir(@resource.value(:path), &block)
+ # 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:
+ value = nil
+ Dir.chdir(@resource.value(:path)) do
+ value = yield
+ end
+ value
end
end
diff --git a/lib/puppet/provider/vcsrepo/svn.rb b/lib/puppet/provider/vcsrepo/svn.rb
index fef7b62..0e38769 100644
--- a/lib/puppet/provider/vcsrepo/svn.rb
+++ b/lib/puppet/provider/vcsrepo/svn.rb
@@ -60,7 +60,9 @@ Puppet::Type.type(:vcsrepo).provide(:svn) do
end
end
- def at_path(&block)
+ # 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:
value = nil
Dir.chdir(@resource.value(:path)) do
value = yield