githook

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package githook installs and removes the bones pre-commit hook in the host repository's .git/hooks directory. The hook refuses commits when a bones leaf is running for the workspace and the commit was not initiated by the leaf itself (which sets the BONES_INTERNAL_COMMIT=1 environment variable).

See ADR 0034. The hook is the enforcement seam for the bones substrate; without it, agents can silently bypass the shadow trunk by invoking git commit directly.

Index

Constants

View Source
const EnvSentinel = "BONES_INTERNAL_COMMIT"

EnvSentinel is the environment variable the leaf sets when forking git to land a fanned-in commit. The hook checks for this and allows the commit through. User and agent invocations don't set it, so they fail the hook.

View Source
const Marker = "# bones-managed pre-commit (ADR 0034)"

Marker is a string baked into the hook script that identifies it as bones-installed. Used by Doctor to verify the hook hasn't been overwritten with something unrelated.

View Source
const SavedSuffix = ".bones-saved"

SavedSuffix is appended to a pre-existing pre-commit hook when bones takes over. Install renames the original; Uninstall restores it.

Variables

This section is empty.

Functions

func FindGitDir

func FindGitDir(start string) string

FindGitDir walks up from start until it finds a .git directory or file (the latter for git worktrees). Returns the absolute path to .git, or empty string if none is found before reaching root.

func Install

func Install(gitDir string) error

Install writes the bones pre-commit hook to gitDir/hooks/pre-commit. If a non-bones pre-commit hook already exists, it is renamed to pre-commit.bones-saved so the user's pre-commit policy is preserved (the bones hook execs the saved one after passing its own check). Idempotent: re-installing over an existing bones hook is a no-op.

func IsInstalled

func IsInstalled(gitDir string) (bool, error)

IsInstalled reports whether a bones-managed pre-commit hook is present at gitDir/hooks/pre-commit. Used by Doctor.

func Uninstall

func Uninstall(gitDir string) error

Uninstall removes the bones pre-commit hook. If a pre-commit.bones-saved file exists from a previous Install, it is restored. Idempotent: removing a missing or non-bones hook is a no-op.

Types

This section is empty.

Jump to

Keyboard shortcuts

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