Whole file
pre-commit/pre-commit-hooks
The author described this change as “Continues processing JSONs even if hook fails (fixes #1038)”. It counts as a record because the check below fails on the code as it stood at 8c24e2c2e and passes on 25cdd5457, with nothing else changed between the two runs.
Projectpre-commit/pre-commit-hooks
Fix saved2024-04-20
Sharing licenceMIT · LICENSE
Change size+13 −9
What the code was meant to do, written into the code itself as a save note
Continues processing JSONs even if hook fails (fixes #1038)
The change
| 115 | 115 | f'Input File {json_file} is not a valid JSON, consider using ' | |
| 116 | 116 | f'check-json', | |
| 117 | 117 | ) | |
| 118 | - | return 1 | |
| 119 | - | ||
| 120 | - | if contents != pretty_contents: | |
| 121 | - | if args.autofix: | |
| 122 | - | _autofix(json_file, pretty_contents) | |
| 123 | - | else: | |
| 124 | - | diff_output = get_diff(contents, pretty_contents, json_file) | |
| 125 | - | sys.stdout.buffer.write(diff_output.encode()) | |
| 126 | - | ||
| 127 | 118 | status = 1 | |
| 119 | + | else: | |
| 120 | + | if contents != pretty_contents: | |
| 121 | + | if args.autofix: | |
| 122 | + | _autofix(json_file, pretty_contents) | |
| 123 | + | else: | |
| 124 | + | diff_output = get_diff( | |
| 125 | + | contents, | |
| 126 | + | pretty_contents, | |
| 127 | + | json_file, | |
| 128 | + | ) | |
| 129 | + | sys.stdout.buffer.write(diff_output.encode()) | |
| 130 | + | ||
| 131 | + | status = 1 | |
| 128 | 132 | ||
| 129 | 133 | return status | |
| 130 | 134 |
The check that tells the two apart
fail→pass·tests/pretty_format_json_test.py::test_invalid_main
Check file tests/pretty_format_json_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 it8c24e2c2e6b964feb04e1a93a72200ee84bd115a
Broken version dated2024-04-20
Modulepre_commit_hooks.pretty_format_json
Units changedmain
Fingerprint9bb2919ab75858e1
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
- 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-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