pub fn run_hooks(opts: HookOptions<'_>) -> Result<()>Expand description
Execute a list of hook commands with the given options.
Each command is executed sequentially with the specified environment variables.
If strict mode is enabled, any command failure will return an error.
Otherwise, failures are printed as warnings and execution continues.
§Errors
Returns an error if a command fails in strict mode, if a command cannot be spawned, or if a command times out.
§Examples
use std::time::Duration;
use rusty_commit::utils::hooks::{run_hooks, HookOptions};
let opts = HookOptions {
name: "pre-commit",
commands: vec!["echo 'Running tests'".to_string()],
strict: true,
timeout: Duration::from_secs(30),
envs: vec![("RCO_VAR", "value".to_string())],
};
let result = run_hooks(opts);