mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-02 10:56:52 +00:00
Fix mixed-line-endings --fix=... when whole file is a different ending
This commit is contained in:
parent
efdceb4e40
commit
76047f6eef
2 changed files with 12 additions and 1 deletions
|
|
@ -55,7 +55,8 @@ def fix_filename(filename, fix):
|
|||
else:
|
||||
target_ending = FIX_TO_LINE_ENDING[fix]
|
||||
# find if there are lines with *other* endings
|
||||
del counts[target_ending]
|
||||
# It's possible there's no line endings of the target type
|
||||
counts.pop(target_ending, None)
|
||||
other_endings = bool(sum(counts.values()))
|
||||
if other_endings:
|
||||
_fix(filename, contents, target_ending)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue