Repository navigation
fix(144): keep the commit-msg hook from crashing on a message that is not UTF-8 - #147
Conversation
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
c0ee438 to
2f3cb64
Compare
Verdict: REJECTReviewed head Findings
What holds:
EvidenceRequired checks on Local full check ( The proof's demo (the issue's reproduction) on the head: Finding 1: The same with the template at — robocop |
Factory ledgerWhat the loops spent on this so far, summed from the loop runtime's records. Cost is at API prices; the loops run on a subscription, so it measures plan usage, not a bill.
Updated automatically. |
2f3cb64 to
5074573
Compare
|
Round 1, finding 1: fixed in 5074573 (folded into the fix commit). All four decodes of the hook now use — chuck-norris |
Verdict: REJECTReviewed head Round-1 finding 1 is fixed. An unchanged template at a path that is not UTF-8 now aborts with "you did not edit the message", and so does a template with Latin-1 content (transcript below). Findings
Information only: ruff's structural check is clean on EvidenceRequired checks on Local full check ( Round-1 finding, re-run on the head ( The proof's demo on the head: Finding 1, with the hook run as The wrapper that simulates git ≥ 2.45 with
|
… not UTF-8 The hook read the message with a strict UTF-8 decode, and decoded the output of its own git calls with the locale, so a Latin-1 message (or comment character, or template path) ended the commit with a UnicodeDecodeError traceback. Decisions: the text is only classified (editor used, blank, untouched template), never written back, so it is decoded with errors="surrogateescape" (every byte stays distinct, so a template path or content that is not UTF-8 is still found and compared equal); git interpret-trailers rewrites the file and keeps its bytes. The same decoding goes on the two git calls of the hook, as git() in git.py has had since #135. The hook keeps its own subprocess calls: it needs stdin for stripspace and check=True. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Loop: chuck-norris
5074573 to
8b2a270
Compare
|
Round 2, finding 1: fixed in 8b2a270 (folded into the fix commit). New spec CI is green on 8b2a270: https://github.com/CapeOfGoodCode/prepush-ci/actions/runs/38460586400 — chuck-norris |
Verdict: APPROVECode review round 3 of #147 at head FindingsNone. The round 2 finding is fixed: Notes (not findings):
Evidence
It changes the tool's code, so it goes to — robocop |
Attack: PASSHead: 8b2a270 · 15 hypotheses · 0 broken by this PR Each run with the hook installed in a throwaway repository,
Hypothesis from review ( Reproduction scripts
— terminator |
Closes #144
What changes
The commit-msg hook no longer ends the commit with a
UnicodeDecodeErrortraceback when the message (or the repository's comment character or template path) is not valid UTF-8: the message is only classified, never written back, so it is read witherrors="surrogateescape"; the hook's owngit configandgit stripspacecalls use the same error handler, andgit stripspaceis decoded as UTF-8 like the message, whatever the locale.git interpret-trailerskeeps the file's bytes. No spec change (triaged on the issue).Proof
Acceptance
test_a_message_that_is_not_utf8_gets_the_trailer_with_its_bytes_keptgit commit -F:test_a_commit_message_that_is_not_utf8_is_committed_with_the_trailertest_a_commit_template_path_that_is_not_utf8_does_not_stop_the_trailer,test_a_message_of_comment_lines_with_a_comment_char_that_is_not_utf8_is_left_unchanged,test_a_message_of_comment_lines_with_a_comment_string_of_two_bytes_is_left_unchanged_under_an_ascii_localeDemo (scratch repository
/tmp/demo144, the reproduction of the issue)(The warning is git's own; on
mainthe hook ends inUnicodeDecodeErrorand no commit is made.)Check: CI on 8b2a270: 1274 passed (Linux, 3.14, same on 3.11 and Windows), 100% branch coverage of core, 99% overall, specs valid 13/13 (run); the comment-character spec is skipped on Windows (Git for Windows does not hand a raw non-UTF-8 comment byte back unchanged).
Details for the reviewer
Decoding is
errors="surrogateescape"everywhere (message,_git_config,_comment_prefix, template content), so every byte stays distinct and a template path or content that is not UTF-8 is still found and compared. Mutants, each seen failing: puttingreplaceback on any one of the four reads. Onlycommit_msg_hook_spec.pyandtests/unitwere run locally; the full suite runs on GitHub. Git re-encodes the stored message to UTF-8, so the commit spec compares withé.— chuck-norris