githook

package
v1.98.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2026 License: BSD-3-Clause Imports: 15 Imported by: 0

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

View Source
var HookVersion string

HookVersion is the shared version of this package and launcher.sh. Bump HOOK_VERSION on any change under this package.

View Source
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

func AddChangeID(args []string) error

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

func CheckGoModReplaces(args []string, watchedRemotes, allowedReplaceDirs []string) error

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

func RunLocalHook(hookName string, args []string) error

RunLocalHook runs an optional user-supplied hook at .git/hooks/<name>.local, if present.

func WriteHooks

func WriteHooks(hooks []string) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL