Skip to main content

Module hooks

Module hooks 

Source
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

HookWhenDescription
pre-commitBefore suture commit finalizesValidate staged content, run linters/tests
post-commitAfter suture commit succeedsSend notifications, trigger CI
pre-pushBefore suture push sends to hubRun tests, enforce policy
post-pushAfter suture push succeedsSend notifications, trigger deployment
pre-mergeBefore suture merge finalizesValidate merge safety
post-mergeAfter a clean suture merge succeedsSend notifications
pre-rebaseBefore suture rebase replays patchesValidate rebase safety
post-rebaseAfter suture rebase completesSend notifications
pre-cherry-pickBefore suture cherry-pick applies a patchValidate cherry-pick safety

§Hook Configuration

  • Hooks directory: .suture/hooks/ (or override via core.hooksPath in .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

VariableDescription
SUTURE_HOOKName of the hook being run
SUTURE_REPOAbsolute path to the repository root
SUTURE_AUTHORCurrent author name
SUTURE_BRANCHCurrent branch name
SUTURE_HEADFull hash of the current HEAD patch
SUTURE_OPERATIONOperation being performed
SUTURE_HOOK_DIRPath to the hooks directory
SUTURE_DIFF_FILESSpace-separated list of changed file paths (pre-commit)
SUTURE_PUSH_REMOTERemote name (pre-push)
SUTURE_PUSH_PATCHESNumber of patches being pushed (pre-push)
SUTURE_MERGE_SOURCESource branch name (pre-merge)
SUTURE_MERGE_HEADHEAD patch hash at merge time (pre-merge)
SUTURE_REVERT_TARGETPatch being reverted (pre-revert)

Structs§

HookResult
The result of running a hook.

Enums§

HookError
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).