mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-25 19:21:18 -08:00
The launcher found the shared HOOK_VERSION via `go list -m -f
'{{.Dir}}' tailscale.com`. But go list -m doesn't download modules, so
after a repo bumps its tailscale.com dependency to a version not yet in
the module cache, Dir is empty, SHARED_VER falls back to 0, and the
launcher rebuilds ts-git-hook-bin even though the shared HOOK_VERSION
didn't change. In corp, which can sometimes bump OSS a few times a
day, that meant a spurious "git-hook: rebuilding ts-git-hook-bin..."
(plus a module download) on the first git operation after most bumps.
If Dir is empty, run `go mod download tailscale.com` and look again.
The rebuild was going to download the module anyway.
Bump HOOK_VERSION so existing installs pick up the new launcher.
Updates tailscale/corp#40381
Change-Id: I6e4720702d7052df3b15dce0c60a8b313c6b48e3
Signed-off-by: Brad Fitzpatrick <[email protected]>
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/add-git-hooks.go
The script auto-updates in the future.
Large file check
The pre-push hook rejects pushes that add or change any blob over 1.5 MB, using the same tree diff logic as the check-file-size CI workflow. To push a large file intentionally, set an environment variable:
TS_SKIP_LARGE_FILE_CHECK=1 git push ...
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.
Version bumps
The launcher rebuilds when the installed binary's version differs from the concatenation of two files:
githook/HOOK_VERSION(shared): bump when changing anything undergithook/orgit-hook.go. Downstream repos pick it up after bumping theirtailscale.comdependency.misc/git_hook/HOOK_VERSION(repo-local, optional): bump to force a rebuild for repo-specific config changes without touching the shared version. This repo does not use one.