Repository navigation
Guard the hook line hooks install prints when proofline is not on PATH - #129
Open
ammartahamohamedy wants to merge 1 commit into
Open
ammartahamohamedy wants to merge 1 commit into
ammartahamohamedy wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #128
Problem
With
core.hooksPathset (Husky, lefthook), or when another tool's hook already exists,hooks installprints a bareproofline hook run <hook> "$@"to paste. In a clone withoutprooflineon PATH, that line fails with status 127 andonIncompletenever applies:sh -e(Husky) or as the last line, Git refuses the commit even underwarn;blockdoesn't block.The script
hooks installwrites itself (Hook::script()) already guards this case.Fix
Hook::snippet(). It wraps the unchangedHook::line()in the samecommand -vcheck andonIncompletepolicy thatscript()uses.hooks installprints it in both advice spots.execand noexit 0, so the commands after it still run:|| exit $?);warn, it leaves status 0, also as the last line undersh -e;block, it exits 1.line()is unchanged. It's still a substring of the snippet, socontains(&hook.line())(feat(hooks): add proofline hooks status subcommand #77hooks status, feat(cli): add proofline doctor diagnostics command (--json, --offline) #99doctor) still recognizes a pasted snippet.script()is byte-identical, so uninstall still recognizes installed hooks, andhook runis untouched.The advice now reads:
Tests (written first, both failed before the fix)
install_writes_only_its_own_scripts_and_uninstall_removes_only_them(extended)line()and now also the guardthe_advice_for_a_hooks_path_applies_the_policy_when_proofline_is_not_on_path(new).husky/pre-committwice: ahead of another command, then as the last line underset -e. It then commits with and withoutprooflineon PATH, underwarnandblock(8 commits). A commit lands only underwarn, the later command runs only then, and the note appears only whenprooflineis missingMutation checks: each of these makes the new test fail:
|| exit $?;exit 0after the note;execon the line;[ … ] && exit 1as the snippet's last command.End to end, with the built binary: I pasted the printed advice into a Husky-style hook with
set -eand a laterecho, then committed withoutprooflineon PATH:warn, the commit is created, with the note, and the later command runs;block, Git exits 1.Checks
cargo fmt --check: ✅cargo clippy --locked -- -D warnings: clean on the lib, the bins andtests/hooks.rs.--all-targetsstops at the 2 errorsmainalready has on Windows (src/agent/tests.rs).cargo test --locked: the changed and new tests pass. On Windows, 9 tests fail outside the code this PR changes (mcp, agent install, update, local patch). One isa_push_reviews_the_branches_it_updates_and_skips_tags_and_deletions, which rejects a Windows path push URL through the unchangedscript().cargo deny check: no dependency changes.checkandwindowspass.Proofline review log
Fork review PR: ammar-taha-dev#1. Rounds capped at 2.
The prompts below are from the session that implemented this change; the investigation and reproduction happened in earlier sessions.