Repository navigation
Description
proofline hooks install gives one of two outputs, and only one of them handles a missing proofline:
- No hooks path: it writes
Hook::script()(src/hooks.rs:79). The script checkscommand -v prooflinefirst. Ifprooflineis missing, it prints a note and appliesonIncomplete; the defaultwarnexits 0. core.hooksPathset (Husky, lefthook, a shared.githooks), or another tool's hook already there: it writes nothing and printsHook::line()to paste (hooks.rs:155-160,:188-192). That line is a bareproofline hook run pre-commit "$@".
A hooks path is usually committed, so the pasted line runs in every clone, including clones where proofline isn't on PATH. There sh fails with status 127, and Proofline never starts, so onIncomplete can't apply:
- under
sh -e(how Husky runs hooks) or as the last line, Git refuses the commit even underwarn; - ahead of other commands, the failure is ignored, so
onIncomplete=blockdoesn't block.
Who hits it
- A developer who has Proofline installed, when an IDE or GUI Git client starts without the shell's PATH (
~/.cargo/bin, say). Reinstalling doesn't help. - Everyone else who commits in the repo. Husky's
preparescript setscore.hooksPathonnpm install, so the hook also reaches outside contributors, CI jobs and bots that commit, and devcontainers.
Severity is medium-low. Where a team requires Proofline, command not found does tell people what to install. But script() already treats a missing binary as "not reviewed, apply onIncomplete", and the printed line should do the same.
Reproduce (offline, no sign-in)
git init -q demo && cd demo && git commit -q --allow-empty -m base
git config core.hooksPath .husky
proofline hooks install --pre-commit # writes nothing, prints the line
mkdir .husky && printf '#!/bin/sh\nproofline hook run pre-commit "$@"\n' > .husky/pre-commit
chmod +x .husky/pre-commit
echo x > f && git add f
PATH=/usr/bin:/bin git commit -m test # a PATH without proofline
# .husky/pre-commit: line 2: proofline: command not found
# git exits 1 and no commit is created, although onIncomplete is unset (warn)Proposed fix
Print a guarded snippet built around line(), with the same command -v check and onIncomplete policy as script(). The snippet ends up among other commands in the same file, so it must not exec or exit 0.
Keep line() itself unchanged: open PRs #77 (hooks status) and #99 (doctor) recognize a Proofline hook by contains(&hook.line()), and that check still matches a pasted snippet that contains the line.
Activity