Documentation
¶
Overview ¶
Package githook contains the shared implementation of Tailscale's git hooks. The tailscale/tailscale and tailscale/corp repositories each have a thin main package that dispatches to this one, calling individual hook functions with per-repo arguments as needed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var HookVersion string
HookVersion is the shared version of this package and launcher.sh. Bump HOOK_VERSION on any change under this package.
var Launcher []byte
Launcher is the canonical bytes of launcher.sh. Downstream repos (e.g. tailscale/corp) rely on these bytes at install time.
Functions ¶
func AddChangeID ¶
AddChangeID strips comments from the commit message at args[0] and prepends a random Change-Id trailer.
Intended as a commit-msg hook. https://git-scm.com/docs/githooks#_commit_msg
func CheckForbiddenMarkers ¶
func CheckForbiddenMarkers() error
CheckForbiddenMarkers scans the staged diff for forbidden markers and returns an error if any are found.
Intended as a pre-commit hook. https://git-scm.com/docs/githooks#_pre_commit
func CheckGoModReplaces ¶
CheckGoModReplaces reads pushes from stdin and, for pushes to a remote URL in watchedRemotes, rejects any commit whose go.mod has a directory-path replace that is not in allowedReplaceDirs. args is the pre-push hook's argv (remoteName, remoteLoc).
Intended as a pre-push hook. https://git-scm.com/docs/githooks#_pre_push
func Install ¶
func Install() error
Install writes the launcher to .git/hooks/ts-git-hook and runs it once with "version", bootstrapping the binary build and per-hook wrappers. Called from each repo's misc/install-git-hooks.go.
func RunLocalHook ¶
RunLocalHook runs an optional user-supplied hook at .git/hooks/<name>.local, if present.
func WriteHooks ¶
WriteHooks writes the launcher to .git/hooks/ts-git-hook and a wrapper for each name in hooks to .git/hooks/<name>. Stale wrappers from prior versions (ours, but no longer in hooks) are removed. If a path we are about to write exists and is not one of our wrappers, WriteHooks aborts with an error rather than clobber the user's hook. Called by the binary's "install" handler (after a rebuild) and by Install (initial setup).
Types ¶
This section is empty.