[#1] Fail if all files are reset to committed version.

This commit is contained in:
Sven Weidauer 2022-06-06 10:18:05 +02:00
parent d00760732d
commit ba54c407cb
4 changed files with 40 additions and 9 deletions

View file

@ -28,9 +28,15 @@ module FormatStaged
end
def run
matching_files(repo_root).each do |file|
format_file(file)
files = matching_files(repo_root)
if files.empty?
info 'No staged file matching pattern. Done'
return true
end
formatted = files.filter { |file| format_file file }
!formatted.empty?
end
def repo_root
@ -57,7 +63,7 @@ module FormatStaged
if new_hash == file.dst_hash
info "Unchanged #{file.src_path}"
return false
return true
end
if object_is_empty new_hash
@ -68,6 +74,11 @@ module FormatStaged
replace_file_in_index file, new_hash
update_working_copy file, new_hash
if new_hash == file.src_hash
info "File #{file.src_path} equal to comitted"
return false
end
true
end