diff options
author | Bruce Williams <bruce@codefluency.com> | 2010-03-12 18:34:03 -0800 |
---|---|---|
committer | Bruce Williams <bruce@codefluency.com> | 2010-03-12 18:34:03 -0800 |
commit | abd973080207906c32831ff315b9f7a6d2bcb872 (patch) | |
tree | 5466269802704e6565806499ab720e6d0b5f3b74 /lib | |
parent | 350972d6be26cacdcb18875055f9723574312966 (diff) |
Tests for Git revision property, cleanup
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/provider/vcsrepo/git.rb | 18 | ||||
-rw-r--r-- | lib/puppet/provider/vcsrepo/svn.rb | 4 |
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 |