From 5f8af000eec1e7cd8543e84f8093b4a62701e285 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Sun, 29 May 2022 09:45:13 +0200 Subject: [PATCH] More refactoring --- lib/format_staged.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) 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}"