Repository navigation
AP-1582 Run changed-file checks before pushes - #8519
erwan-leforestier-sonarsource wants to merge 4 commits into
Conversation
5be605f to
f2e8a33
Compare
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "bash .agents/hooks/pre-push.sh", |
There was a problem hiding this comment.
💡 Edge Case: Codex/Tirion hook commands use a cwd-relative script path
.codex/hooks.json and .tirion/hooks.json run bash .agents/hooks/pre-push.sh, which only resolves when the agent session's working directory is the repository root. If the session starts in a subdirectory (e.g. packages/analysis), bash exits 127 with 'No such file or directory'. The hook then fails as non-blocking and no pre-push check runs. The Claude config avoids this by using $CLAUDE_PROJECT_DIR. Resolve the script from the git toplevel instead.
Resolve the script from the repository root:
"command": "bash "$(git rev-parse --show-toplevel)/.agents/hooks/pre-push.sh"",
- Apply fix
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
| const gitLocation = /^(?:GIT_DIR|GIT_WORK_TREE|GIT_COMMON_DIR)(?:=|$)/; | ||
| const directoryCommands = new Set(['cd', 'pushd', 'popd']); |
There was a problem hiding this comment.
💡 Edge Case: Any cd/pushd now skips the agent check, even within the same checkout
changesCheckout returns false for the whole command as soon as any segment starts with cd, pushd or popd. It does not check where the command changes to. So cd /work/repo && git push, cd tools && git push and (cd sub && make); git push all skip the agent check, even though the push still runs in the checkout that owns the hook. Agents emit the cd <repo> && git push form all the time. BUILD.md (line 23) only says pushes that use Git global options like -C/--git-dir are left to Git, so the cd and GIT_DIR= cases are undocumented. Where Husky is not installed, the push gets no check at all. Fix: resolve the cd target against the payload cwd and skip only when it leaves the owning checkout, or at least document that any directory change skips the agent check.
Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 🔴 High risk 8 closed / 10 findingsRepository policy: agent and Husky hooks enforce changed-file checks before pushes, potentially blocking pushes on findings and changing required validation controls. Adds changed-file mise checks to agent and human pushes, reporting actionable findings, logging unavailable checks locally, and reusing passing agent checks in the Git hook. Approved with suggestions: Codex and Tirion hook commands use a cwd-relative 💡 Edge Case: Codex/Tirion hook commands use a cwd-relative script path📄 .codex/hooks.json:9 📄 .tirion/hooks.json:10 📄 .claude/settings.json:9
Resolve the script from the repository root💡 Edge Case: Any cd/pushd now skips the agent check, even within the same checkout📄 tools/agent-hooks/push-command.mjs:21-22 📄 tools/agent-hooks/push-command.mjs:37-42 📄 tools/agent-hooks/push-command.mjs:68-80 📄 docs/systems/infra/BUILD.md:23
✅ 8 closed✅ Bug: Non-canonical license headers will fail license:headers
✅ Bug: Internal time budgets exceed the 260s agent hook timeout
✅ Edge Case: Main-module guard silently disables hooks under symlinked paths
✅ Security: Task passes if its output contains a 'Finished in' line
✅ Edge Case: Detached mise batch survives Ctrl-C on a human git push
...and 3 more closed from earlier reviews 🤖 Prompt for agentsVerification Rules 4/4 met PRs 2 inspectedFunctional validation No results Rules 4 passed 3 not applicable
Broader impact PRs 2 inspectedCross-PR 2 PRs inspected 0 open impacts
Auto-approval Not enabledFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
Part of AP-1486. Implements AP-1582.
Summary by Gitar
mise run install:npmfor Husky setup.claude/settings.jsonand.codex/hooks.jsonin.gitignoreagent-hooks/last.jsonunder the Git directory, not committedpre-push.shadapterThis will update automatically on new commits.