Expand description
Hook system for Suture — git-compatible hook execution.
Hooks are executable scripts found in .suture/hooks/<hook-name> that are
run at specific points in the Suture workflow. A hook exits with 0 to allow
the operation to proceed, or non-zero to abort.
§Supported Hooks
| Hook | When | Description |
|---|---|---|
pre-commit | Before suture commit finalizes | Validate staged content, run linters/tests |
post-commit | After suture commit succeeds | Send notifications, trigger CI |
pre-push | Before suture push sends to hub | Run tests, enforce policy |
post-push | After suture push succeeds | Send notifications, trigger deployment |
pre-merge | Before suture merge finalizes | Validate merge safety |
post-merge | After a clean suture merge succeeds | Send notifications |
pre-rebase | Before suture rebase replays patches | Validate rebase safety |
post-rebase | After suture rebase completes | Send notifications |
pre-cherry-pick | Before suture cherry-pick applies a patch | Validate cherry-pick safety |
§Hook Configuration
- Hooks directory:
.suture/hooks/(or override viacore.hooksPathin.suture/config) - Hooks are executable files named exactly by their hook type (e.g.,
pre-commit) - Non-executable files or missing hooks are silently skipped
- Hook scripts receive environment variables with context about the operation
§Environment Variables
| Variable | Description |
|---|---|
SUTURE_HOOK | Name of the hook being run |
SUTURE_REPO | Absolute path to the repository root |
SUTURE_AUTHOR | Current author name |
SUTURE_BRANCH | Current branch name |
SUTURE_HEAD | Full hash of the current HEAD patch |
SUTURE_OPERATION | Operation being performed |
SUTURE_HOOK_DIR | Path to the hooks directory |
SUTURE_DIFF_FILES | Space-separated list of changed file paths (pre-commit) |
SUTURE_PUSH_REMOTE | Remote name (pre-push) |
SUTURE_PUSH_PATCHES | Number of patches being pushed (pre-push) |
SUTURE_MERGE_SOURCE | Source branch name (pre-merge) |
SUTURE_MERGE_HEAD | HEAD patch hash at merge time (pre-merge) |
SUTURE_REVERT_TARGET | Patch being reverted (pre-revert) |
Structs§
- Hook
Result - The result of running a hook.
Enums§
- Hook
Error - Errors that can occur during hook execution.
Functions§
- build_
env - Build the standard environment variables for a hook invocation.
- format_
hook_ result - Format hook results for display to the user.
- hooks_
dir - Find the hooks directory for a repository.
- run_
hook - Run a hook script and capture its output.
- run_
hooks - Run all hooks of a given type from a directory (for extensibility).