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 ¶
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.
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.
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 ¶
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 ¶
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 ¶
IsInstalled reports whether a bones-managed pre-commit hook is present at gitDir/hooks/pre-commit. Used by Doctor.
Types ¶
This section is empty.