Files
coder/scripts/githooks/pre-push
T
Mathias Fredriksson dd34e3d3c2 fix(scripts/githooks): prevent agents from bypassing git hooks (#22825)
Agents hit short shell timeouts on `git commit` (~13s) before
`make pre-commit` finishes (~20s warm), then disable hooks via
`git config core.hooksPath /dev/null`. This bypasses all local checks
and, because it writes to shared `.git/config`, silently disables hooks
for every other worktree too.

Add explicit timing guidance to AGENTS.md, and write worktree-scoped
`core.hooksPath` in post-checkout, pre-commit, and pre-push hooks to
make the bypass ineffective.
2026-03-09 12:51:44 +02:00

27 lines
792 B
Bash
Executable File

#!/usr/bin/env bash
#
# Pre-push hook that runs the full CI suite locally.
# Runs `make pre-push` (gen, fmt, lint, typos, build, tests)
# to catch issues before they reach CI.
#
# The pre-commit hook already runs the lite checks on each commit.
# This hook adds the heavier checks (test-postgres, test-js,
# test-e2e, sqlc-vet, offlinedocs) before pushing.
#
# Installation (worktree-compatible):
#
# git config core.hooksPath scripts/githooks
#
# Bypass: git push --no-verify
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
unset GIT_DIR
# In linked worktrees, set worktree-scoped hooksPath to override shared config.
if [[ "$(git rev-parse --git-dir)" != "$(git rev-parse --git-common-dir)" ]]; then
git config --worktree core.hooksPath scripts/githooks
fi
exec make pre-push