feat: switch git hook from pre-commit to pre-push#5
Conversation
Less intrusive review trigger — runs before pushing to remote instead of blocking every commit. The hook reads the pre-push stdin protocol and uses --branch to review only changes not yet on the remote. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c29cfd13e0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
src/commands/hook/install.ts
Outdated
| branch_name="\${remote_ref#refs/heads/}" | ||
|
|
||
| # Review changes not yet on the remote | ||
| kodus review --branch "\${remote}/\${branch_name}" ${reviewFlags} |
There was a problem hiding this comment.
Review pushed ref instead of current HEAD
The generated hook calls kodus review --branch "${remote}/${branch_name}", but review --branch compares the current branch to the provided base (getDiffForBranch runs git diff <branch>...HEAD, and the option text says “Compare current branch…”). If someone pushes a ref that is not currently checked out (for example git push origin feature while on main), the hook reviews the wrong diff, which can miss issues in the pushed ref or block push for unrelated changes.
Useful? React with 👍 / 👎.
src/commands/hook/install.ts
Outdated
|
|
||
| # Review changes not yet on the remote | ||
| kodus review --branch "\${remote}/\${branch_name}" ${reviewFlags} | ||
| exit $? |
There was a problem hiding this comment.
Process every pushed ref before exiting hook
The script reads ref updates in a while read ... loop but exits immediately after the first reviewed ref. In multi-ref pushes (e.g., git push --all or pushing multiple refspecs), only the first eligible ref is analyzed and all later refs bypass review, so part of the pushed changes are never checked.
Useful? React with 👍 / 👎.
|
To improve tracking and context, please update the pull request description to include a reference to the corresponding issue, using a keyword like 'Closes #issue_number' or 'Fixes #issue_number'. Kody Rule violation: Ensure PR closes referenced issues |
--branch compares against HEAD, so reviewing a ref that doesn't match the current branch would produce wrong diffs. Now the hook extracts the branch name from local_ref and only runs the review when it matches the currently checked-out branch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
Exit only on failure instead of unconditionally after the first review, so all pushed branches get reviewed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The pull request description does not reference any issues. To improve tracking and provide context, please edit the description to include a reference to the issue this PR addresses, for example, 'Closes #123' or 'Fixes #456'. Kody Rule violation: Ensure PR closes referenced issues |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
|
The pull request description does not reference any issues. To improve tracking and context, please edit the description to include a keyword like |
Less intrusive review trigger — runs before pushing to remote instead of blocking every commit. The hook reads the pre-push stdin protocol and uses --branch to review only changes not yet on the remote.
This pull request switches the Git hook managed by the
kodusCLI frompre-committopre-push.Key changes include:
kodus hookcommands (install, uninstall, status) now manage apre-pushGit hook instead of apre-commithook.pre-pushhook script includes logic to:pre-pusharguments (remote, local/remote refs/SHAs).kodus reviewusing the--branchflag to compare the local branch against its remote.--fail-onnow blocks push), prompts, and console messages have been updated to refer to "pre-push hook" instead of "pre-commit hook"..git/hooks/pre-push.KODUS_SKIP_HOOK=1 git committoKODUS_SKIP_HOOK=1 git push.