Skip to main content

Module hooks

Module hooks 

Source
Expand description

Git hook management — sync, execution, and validation.

Keeps .githooks/ in sync with the hooks section of sr.yaml and provides the runtime for executing configured hook entries.

Functions§

build_hook_json
Build a JSON context object for a git hook based on its name and positional args.
needs_sync
Check whether hooks need syncing (cheap hash comparison).
run_hook
Run all entries for a configured git hook.
run_shell
Run a shell command (sh -c), optionally piping data to stdin and/or injecting environment variables. Returns an error if the command exits non-zero.
sync_hooks
Sync .githooks/ with the hooks config. Returns Ok(true) if changes were made.
validate_commit_msg
Validate a commit message file against the configured conventional commit pattern and types. Reads hook JSON from stdin to get the message_file path.