diff --git a/lib/format_staged.rb b/lib/format_staged.rb index a98964b..7cb9759 100644 --- a/lib/format_staged.rb +++ b/lib/format_staged.rb @@ -61,18 +61,21 @@ class FormatStaged end replace_file_in_index file, new_hash - - if update - begin - patch_working_file file, new_hash - rescue StandardError => e - warning "failed updating #{file.src_path} in working copy: #{e}" - end - end + update_working_copy file, new_hash true end + def update_working_copy(file, new_hash) + return unless update + + begin + patch_working_file file, new_hash + rescue StandardError => e + warning "failed updating #{file.src_path} in working copy: #{e}" + end + end + def format_object(file) info "Formatting #{file.src_path}"