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.

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

2929 # type: (bytes, bool, Optional[bytes]) -> bytes
3030 if line[-2:] == b'\r\n':
3131 eol = b'\r\n'
32+ line = line[:-2]
3233 elif line[-1:] == b'\n':
3334 eol = b'\n'
35+ line = line[:-1]
3436 else:
3537 eol = b''
3638 # 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
3941 return line.rstrip(chars_to_strip) + eol
4042
4143

The check that tells the two apart

failpass·tests/trailing_whitespace_fixer_test.py::test_custom_charset_change
failpass·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