Whole file
pre-commit/pre-commit-hooks
The author described this change as “fix-whitespace: Added test for custom charsets”. It counts as a record because the checks below fail on the code as it stood at 08663c91f and pass on a2f836a23, with nothing else changed between the two runs.
Projectpre-commit/pre-commit-hooks
Fix saved2019-10-25
Sharing licenceMIT · LICENSE
Change size+4 −2
What the code was meant to do, written into the code itself as a save note
fix-whitespace: Added test for custom charsets
The change
| 29 | 29 | # type: (bytes, bool, Optional[bytes]) -> bytes | |
| 30 | 30 | if line[-2:] == b'\r\n': | |
| 31 | 31 | eol = b'\r\n' | |
| 32 | + | line = line[:-2] | |
| 32 | 33 | elif line[-1:] == b'\n': | |
| 33 | 34 | eol = b'\n' | |
| 35 | + | line = line[:-1] | |
| 34 | 36 | else: | |
| 35 | 37 | eol = b'' | |
| 36 | 38 | # preserve trailing two-space for non-blank lines in markdown files | |
| 37 | - | if is_markdown and (not line.isspace()) and line.endswith(b' ' + eol): | |
| 38 | - | return line.rstrip(chars_to_strip) + b' ' + eol | |
| 39 | + | if is_markdown and (not line.isspace()) and line.endswith(b' '): | |
| 40 | + | return line[:-2].rstrip(chars_to_strip) + b' ' + eol | |
| 39 | 41 | return line.rstrip(chars_to_strip) + eol | |
| 40 | 42 | ||
| 41 | 43 |
The check that tells the two apart
fail→pass·tests/trailing_whitespace_fixer_test.py::test_custom_charset_change
fail→pass·tests/trailing_whitespace_fixer_test.py::test_custom_charset_no_change
Check file tests/trailing_whitespace_fixer_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 it08663c91f2362aa70fe0b5e9dc389823a46c66bf
Broken version dated2019-10-25
Modulepre_commit_hooks.trailing_whitespace_fixer
Units changed_process_line
Fingerprint51c015beb443d6df
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-05-15Handle crlf endings in fix-encoding-pragma
- 2017-09-27Fix mixed-line-endings --fix=... when whole file is a different ending
- 2017-06-25Fix bug with the file-contents-sorter hook when processing file that does not end in a newline