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.

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

115115 f'Input File {json_file} is not a valid JSON, consider using '
116116 f'check-json',
117117 )
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-
127118 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
128132
129133 return status
130134

The check that tells the two apart

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