Whole file
pre-commit/pre-commit-hooks
The author described this change as “Fix mixed-line-endings --fix=... when whole file is a different ending”. It counts as a record because the check below fails on the code as it stood at efdceb4e4 and passes on 76047f6ee, with nothing else changed between the two runs.
Projectpre-commit/pre-commit-hooks
Fix saved2017-09-27
Sharing licenceMIT · LICENSE
Change size+2 −1
What the code was meant to do, written into the code itself as a save note
Fix mixed-line-endings --fix=... when whole file is a different ending
The change
| 55 | 55 | else: | |
| 56 | 56 | target_ending = FIX_TO_LINE_ENDING[fix] | |
| 57 | 57 | # find if there are lines with *other* endings | |
| 58 | - | del counts[target_ending] | |
| 58 | + | # It's possible there's no line endings of the target type | |
| 59 | + | counts.pop(target_ending, None) | |
| 59 | 60 | other_endings = bool(sum(counts.values())) | |
| 60 | 61 | if other_endings: | |
| 61 | 62 | _fix(filename, contents, target_ending) |
The check that tells the two apart
fail→pass·tests/mixed_line_ending_test.py::test_fix_lf_all_crlf
Check file tests/mixed_line_ending_test.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itefdceb4e40cda10780f4646ec944f55b5786190d
Broken version dated2017-09-19
Modulepre_commit_hooks.mixed_line_ending
Units changedfix_filename
Fingerprintca3eba62b9424e2a
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in pre-commit/pre-commit-hooks
- 2024-04-20Continues processing JSONs even if hook fails (fixes #1038)
- 2020-09-27Fix #518, provide --enforce-all option to check_added_large_files
- 2020-07-30Fix parsing of git output with unusual characters
- 2019-10-25fix-whitespace: Added test for custom charsets
- 2019-05-15Handle crlf endings in fix-encoding-pragma
- 2017-06-25Fix bug with the file-contents-sorter hook when processing file that does not end in a newline