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.

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

5555 else:
5656 target_ending = FIX_TO_LINE_ENDING[fix]
5757 # 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)
5960 other_endings = bool(sum(counts.values()))
6061 if other_endings:
6162 _fix(filename, contents, target_ending)

The check that tells the two apart

failpass·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