diff --git a/AGENTS.md b/AGENTS.md index c8dccceff8..4f70a5ebea 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -105,22 +105,37 @@ app, err := api.Database.GetOAuth2ProviderAppByClientID(ctx, clientID) ### Full workflows available in imported WORKFLOWS.md -### Git Hooks (MANDATORY) +### Git Hooks (MANDATORY - DO NOT SKIP) -Before your first commit, ensure the git hooks are installed. -Two hooks run automatically: +**You MUST install and use the git hooks. NEVER bypass them with +`--no-verify`. Skipping hooks wastes CI cycles and is unacceptable.** -- **pre-commit**: `make pre-commit` (gen, fmt, lint, typos, build). - Fast checks that catch most CI failures. -- **pre-push**: `make pre-push` (full CI suite including tests). - Runs before pushing to catch everything CI would. - -Wait for them to complete, do not skip or bypass them. +The first run will be slow as caches warm up. Consecutive runs are +**significantly faster** (often 10x) thanks to Go build cache, +generated file timestamps, and warm node_modules. This is NOT a +reason to skip them. Wait for hooks to complete before proceeding, +no matter how long they take. ```sh git config core.hooksPath scripts/githooks ``` +Two hooks run automatically: + +- **pre-commit**: `make pre-commit` (gen, fmt, lint, typos, build). + Fast checks that catch most CI failures. Allow at least 5 minutes. +- **pre-push**: `make pre-push` (full CI suite including tests). + Runs before pushing to catch everything CI would. Allow at least + 15 minutes (race tests are slow without cache). + +`git commit` and `git push` will appear to hang while hooks run. +This is normal. Do not interrupt, retry, or reduce the timeout. + +NEVER run `git config core.hooksPath` to change or disable hooks. + +If a hook fails, fix the issue and retry. Do not work around the +failure by skipping the hook. + ### Git Workflow When working on existing PRs, check out the branch first: diff --git a/scripts/githooks/post-checkout b/scripts/githooks/post-checkout new file mode 100755 index 0000000000..fb014912f5 --- /dev/null +++ b/scripts/githooks/post-checkout @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# Shield this worktree against shared config hooksPath poisoning. +# Worktree-scoped config overrides the shared .git/config, so even if +# another worktree runs `git config core.hooksPath /dev/null`, this +# worktree continues to use the correct hooks. +# +# This hook runs on `git worktree add` and `git checkout`/`git switch`. +# Only needed in linked worktrees where shared config can be poisoned +# by another worktree. Skipped in the main checkout to avoid errors +# when extensions.worktreeConfig is not set (e.g. fresh clones). +if [[ "$(git rev-parse --git-dir)" != "$(git rev-parse --git-common-dir)" ]]; then + git config --worktree core.hooksPath scripts/githooks +fi diff --git a/scripts/githooks/pre-commit b/scripts/githooks/pre-commit index ff6f59418b..66ccd4a516 100755 --- a/scripts/githooks/pre-commit +++ b/scripts/githooks/pre-commit @@ -16,4 +16,8 @@ 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-commit diff --git a/scripts/githooks/pre-push b/scripts/githooks/pre-push index 115dee8c2e..f721d517b2 100755 --- a/scripts/githooks/pre-push +++ b/scripts/githooks/pre-push @@ -19,4 +19,8 @@ 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