diff options
author | Seth Chisamore <schisamo@opscode.com> | 2011-02-01 22:35:31 -0500 |
---|---|---|
committer | Daniel DeLeo <dan@opscode.com> | 2011-02-01 19:54:02 -0800 |
commit | 99d5a241849450dedd3c361c59866b947e1de721 (patch) | |
tree | fc105159ba2bd2e42f2f56affd1ebf6c37064c1e /chef/lib/chef/provider/subversion.rb | |
parent | c9bea2d368381fa3944e9e05539c43829cfd4f36 (diff) | |
download | chef-99d5a241849450dedd3c361c59866b947e1de721.tar.gz |
CHEF-2002, sync actions should be idempotent
Diffstat (limited to 'chef/lib/chef/provider/subversion.rb')
-rw-r--r-- | chef/lib/chef/provider/subversion.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/chef/lib/chef/provider/subversion.rb b/chef/lib/chef/provider/subversion.rb index 642560fe0a..1f94c122e1 100644 --- a/chef/lib/chef/provider/subversion.rb +++ b/chef/lib/chef/provider/subversion.rb @@ -55,11 +55,17 @@ class Chef def action_sync if ::File.exist?(::File.join(@new_resource.destination, ".svn")) - run_command(run_options(:command => sync_command)) + current_rev = find_current_revision + Chef::Log.debug "#{@new_resource} current revision: #{current_rev} target revision: #{revision_int}" + unless current_revision_matches_target_revision? + run_command(run_options(:command => sync_command)) + Chef::Log.info "#{@new_resource} updated to revision: #{revision_int}" + @new_resource.updated_by_last_action(true) + end else action_checkout + @new_resource.updated_by_last_action(true) end - @new_resource.updated_by_last_action(true) end def sync_command @@ -110,6 +116,10 @@ class Chef extract_revision_info(svn_info) end + def current_revision_matches_target_revision? + (!@current_resource.revision.nil?) && (revision_int.strip.to_i == @current_resource.revision.strip.to_i) + end + def run_options(run_opts={}) run_opts[:user] = @new_resource.user if @new_resource.user run_opts[:group] = @new_resource.group if @new_resource.group |