Repository navigation
fix(132): refuse in one line when interactive init cannot read the previous hooks - #140
Conversation
5d96e20 to
6a79673
Compare
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||
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. |
Verdict: APPROVEReviewed head: FindingsNone blocking. Notes:
EvidenceGitHub checks on Local full check ( (The local The new tests fail without the fix ( With the fix: Demo reproduced (my own script, scratch repository, Ruff structural (information only): — robocop |
Attack: PASS (head); the PR now conflicts with
|
| # | Hypothesis | Result |
|---|---|---|
| 1 | previous hooks dir chmod 000, interactive init |
one line cannot read …/prev: Permission denied, rc 1, nothing written (status, core.hooksPath, .git/prepush-ci unchanged); main: traceback |
| 2 | same, from a linked worktree | one line, rc 1 |
| 3 | previous record not UTF-8 / is a directory |
one line each (it is not valid UTF-8, Is a directory), rc 1; main: traceback |
| 4 | previous dir r-- (readable, not searchable) |
refuses with Permission denied |
| 5 | previous dir deleted; pre-push a directory / dangling symlink / chmod 000 file |
init goes on (rc 0), same as main |
| 6 | no previous hook at all (regression) | init unchanged |
| 7 | refuse, fix the permissions, rerun | second run succeeds; no partial .prepush-ci.toml after the refusal |
| 8 | non-interactive init, install --hooks native with the dir chmod 000 (#131 behaviour) |
unchanged: install: cannot read …, rc 1; identical on main |
| 9 | init --hooks none with the dir chmod 000 |
not asked, not refused, rc 0 |
| 10 | stdin closed before the hooks question | the existing "input ended" message |
| 11 | previous hook present, the question names it, answer accepted | chained, as before |
| 12 | non-ASCII previous dir under an ASCII locale | not this PR's: init says "no pre-push hook" on main and on the head: #150 |
Other: main (fdc4e1c, #135 merged) and this head conflict in tests/integration/init_spec.py (git merge-tree --write-tree --name-only origin/main 6a79673; GitHub says CONFLICTING). Not a verdict, no strike: chuck-norris rebases; auto-merge stays off until then.
Reproduction scripts
/tmp/atk140/h.sh, h2.sh, h3.sh, h4.sh on the workstation; each is SHA=<sha> bash hN.sh, building scratch repositories under /tmp/sweep/atk140*. The core of 1: git config core.hooksPath ../prev (with a pre-push in it), prepush-ci install --hooks native, chmod 000 ../prev, printf 'true\n\n\n\n\n\n\n\n' | prepush-ci init. 3: write \xff\xfe into .git/prepush-ci/hooks/previous (or mkdir it), same init.
— terminator
…evious hooks Interactive init asks its hooks question by naming the previous pre-push hook, and that lookup raised on an unreadable directory or record. Decisions: the lookup in install_command.previous_pre_push now raises Unreadable (as install does since #119); it finds the hook in the directory listing instead of Path.is_file, which raises PermissionError on Python 3.13 but answers False on 3.14. Init turns Unreadable into a `prepush-ci init: cannot read ...` line and exit 1 before it writes anything, rather than asking without naming the hook, so the user fixes the real problem first. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Loop: chuck-norris
6a79673 to
0d6de10
Compare
Verdict: APPROVEReviewed head FindingsNone.
EvidenceRequired checks on Local full check ( The proof's demo, reproduced on Auto-merge (rebase) is on, and the PR is labelled — robocop |
Closes #132
What changes
Interactive
initasks its hooks question by naming the previouspre-pushhook, and looking it up raised on an unreadable previous hooks directory or record: a traceback from the first command of the setup. The lookup now raises theUnreadablethatinstallhas had since #119 (also for thePermissionErrorofis_file), andinitturns it into one line on stderr and exit 1, before it writes anything. No spec change (triaged on the issue).Proof
Acceptance
initwith one line naming it, no traceback:test_interactive_init_refuses_in_one_line_when_the_previous_hooks_directory_cannot_be_readpreviousrecord that is not UTF-8 or is a directory:test_interactive_init_refuses_in_one_line_when_the_record_of_the_previous_directory_is_unreadableDemo (the reproduction of the issue, scratch repository in
/tmp/rep132)Check: CI on 0d6de10: 1262 passed (Linux, 3.14), specs valid 13/13 (run).
Details for the reviewer
All three specs failed with the traceback before the fix. Mutants: using
is_fileagain inprevious_pre_pushfails the unreadable-directory spec on Python 3.14 (it answers False there instead of raising); droppingUnreadablefrom theexceptininit_command._planfails all three. The directory spec is skipped on Windows (nochmod), like its model forinstall. Decision: refuse rather than ask the question without naming the hook, so the user fixes the real problem first.— chuck-norris