Skip to content

feat: switch git hook from pre-commit to pre-push#5

Merged
malinosqui merged 4 commits intomainfrom
feat/prepush-hook
Feb 14, 2026
Merged

feat: switch git hook from pre-commit to pre-push#5
malinosqui merged 4 commits intomainfrom
feat/prepush-hook

Conversation

@malinosqui
Copy link
Member

@malinosqui malinosqui commented Feb 14, 2026

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 kodus CLI from pre-commit to pre-push.

Key changes include:

  • Hook Type Migration: All kodus hook commands (install, uninstall, status) now manage a pre-push Git hook instead of a pre-commit hook.
  • Review Scope Adjustment: The automated code review, previously triggered on staged files before a commit, will now run on changes between the local branch and its remote counterpart before a push.
  • Updated Hook Script Logic: The generated pre-push hook script includes logic to:
    • Receive pre-push arguments (remote, local/remote refs/SHAs).
    • Skip reviews for branch deletions or when pushing a new branch with no remote state.
    • Extract the branch name from the remote reference.
    • Execute kodus review using the --branch flag to compare the local branch against its remote.
  • CLI Updates:
    • All command descriptions, option descriptions (e.g., --fail-on now blocks push), prompts, and console messages have been updated to refer to "pre-push hook" instead of "pre-commit hook".
    • The path for the hook file is now .git/hooks/pre-push.
    • Instructions for skipping the hook have been updated from KODUS_SKIP_HOOK=1 git commit to KODUS_SKIP_HOOK=1 git push.

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>
@kody-ai

This comment has been minimized.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

branch_name="\${remote_ref#refs/heads/}"

# Review changes not yet on the remote
kodus review --branch "\${remote}/\${branch_name}" ${reviewFlags}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.


# Review changes not yet on the remote
kodus review --branch "\${remote}/\${branch_name}" ${reviewFlags}
exit $?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@kody-ai
Copy link

kody-ai bot commented Feb 14, 2026

kody code-review Kody Rules critical

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>
@kody-ai

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>
@kody-ai
Copy link

kody-ai bot commented Feb 14, 2026

kody code-review Kody Rules critical

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-ai
Copy link

kody-ai bot commented Feb 14, 2026

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Cross File

Access your configuration settings here.

@kody-ai
Copy link

kody-ai bot commented Feb 14, 2026

kody code-review Kody Rules critical

The pull request description does not reference any issues. To improve tracking and context, please edit the description to include a keyword like Closes, Fixes, or Resolves followed by the issue number (e.g., Closes #42). Kody Rule violation: Ensure PR closes referenced issues

@malinosqui malinosqui merged commit cffffb5 into main Feb 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant