Skip to content

Commit cdd3606

Browse files
authored
Merge pull request #2775 from pre-commit/called-process-error-trailing-whitespace
fix trailing whitespace in CalledProcessError output
2 parents 192be60 + 4ded56e commit cdd3606

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

pre_commit/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(
6262
def __bytes__(self) -> bytes:
6363
def _indent_or_none(part: bytes | None) -> bytes:
6464
if part:
65-
return b'\n ' + part.replace(b'\n', b'\n ')
65+
return b'\n ' + part.replace(b'\n', b'\n ').rstrip()
6666
else:
6767
return b' (none)'
6868

tests/staged_files_only_test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,7 @@ def test_failed_diff_does_not_discard_changes(in_git_dir, patch_dir):
425425
r'stdout: \(none\)\n'
426426
r'stderr:\n'
427427
r' error: open\("1"\): Permission denied\n'
428-
r' fatal: cannot hash 1\n'
429-
# TODO: not sure why there's weird whitespace here
430-
r' $',
428+
r' fatal: cannot hash 1$',
431429
).assert_matches(msg)
432430

433431
# even though it errored, the unstaged changes should still be present

tests/util_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
def test_CalledProcessError_str():
19-
error = CalledProcessError(1, ('exe',), b'output', b'errors')
19+
error = CalledProcessError(1, ('exe',), b'output\n', b'errors\n')
2020
assert str(error) == (
2121
"command: ('exe',)\n"
2222
'return code: 1\n'

0 commit comments

Comments
 (0)