summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaire McQuin <mcquin@users.noreply.github.com>2014-06-10 16:24:52 -0700
committerClaire McQuin <mcquin@users.noreply.github.com>2014-06-10 16:24:52 -0700
commit22cda22e26430c7f0a6508d80a5acbfdc99ad4e9 (patch)
tree9882a1b4bdcd697e504c1693d3bd660b00522aa9
parentd9faf7fe80793bdf3dd205b5b777381de93db2b5 (diff)
parent3af439e1086d756434172eb813b279dd257d0f64 (diff)
downloadchef-22cda22e26430c7f0a6508d80a5acbfdc99ad4e9.tar.gz
Merge pull request #1425 from akretion/master
git resource status checking saves 1 shell_out system call
-rw-r--r--lib/chef/provider/git.rb3
-rw-r--r--spec/unit/provider/git_spec.rb4
2 files changed, 3 insertions, 4 deletions
diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb
index 46c8965c7d..3999edc16a 100644
--- a/lib/chef/provider/git.rb
+++ b/lib/chef/provider/git.rb
@@ -95,8 +95,7 @@ class Chef
def action_sync
if existing_git_clone?
- current_rev = find_current_revision
- Chef::Log.debug "#{@new_resource} current revision: #{current_rev} target revision: #{target_revision}"
+ Chef::Log.debug "#{@new_resource} current revision: #{@current_resource.revision} target revision: #{target_revision}"
unless current_revision_matches_target_revision?
fetch_updates
enable_submodules
diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb
index 3986c39ed2..2179db15ff 100644
--- a/spec/unit/provider/git_spec.rb
+++ b/spec/unit/provider/git_spec.rb
@@ -459,7 +459,7 @@ SHAS
it "syncs the code by updating the source when the repo has already been checked out" do
::File.should_receive(:exist?).with("/my/deploy/dir/.git").and_return(true)
::File.stub(:directory?).with("/my/deploy").and_return(true)
- @provider.should_receive(:find_current_revision).exactly(2).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
+ @provider.should_receive(:find_current_revision).exactly(1).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
@provider.should_not_receive(:fetch_updates)
@provider.should_receive(:add_remotes)
@provider.run_action(:sync)
@@ -470,7 +470,7 @@ SHAS
::File.should_receive(:exist?).with("/my/deploy/dir/.git").and_return(true)
::File.stub(:directory?).with("/my/deploy").and_return(true)
# invoked twice - first time from load_current_resource
- @provider.should_receive(:find_current_revision).exactly(2).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
+ @provider.should_receive(:find_current_revision).exactly(1).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c')
@provider.stub(:target_revision).and_return('28af684d8460ba4793eda3e7ac238c864a5d029a')
@provider.should_receive(:fetch_updates)
@provider.should_receive(:enable_submodules)