Fernando Serboncini 1669b0d3d4
misc/git_hook: fix building git_hook in a nested worktree (#19473)
When the repo is checked out as a nested worktree, a go.work in the
outer tree hijacks module resolution, which makes the rebuild fails
with "main module does not contain package." Set GOWORK=off for the
build since the hook is self-contained.

Bumps HOOK_VERSION so existing installs pick up the fix.

Updates #cleanup

Change-Id: Ibd14849efc26e4e1893c5b8e300caa71573f54bd

Signed-off-by: Fernando Serboncini <fserb@fserb.com.br>
2026-04-21 11:42:53 -04:00
..

git_hook

Tailscale's git hooks.

The shared logic lives in the githook/ package and is also imported by tailscale/corp.

Install

From the repo root:

./tool/go run ./misc/install-git-hooks.go

The script auto-updates in the future.

Adding your own hooks

Create an executable .git/hooks/<hook-name>.local to chain a custom script after a built-in hook. For example, put a custom check in .git/hooks/pre-commit.local and chmod +x it. The local hook runs only if the built-in hook succeeds; failure aborts the git operation.

Changing the shared code

When you change anything under githook/ or launcher.sh, bump HOOK_VERSION in the same commit so every dev auto rebuilds on their next git operation.

Because tailscale/corp imports githook/, also plan the downstream update: after landing here, bump corp's tailscale.com dependency and bump corp's own misc/git_hook/HOOK_VERSION on a separate commit. Both are required.