Skip to main content

Module hooks

Module hooks 

Source
Expand description

Post-create and pre-remove hooks (spec §8). Hooks run via sh -c (Unix) or cmd /C (Windows) with the new worktree as the working directory and the WT_* variables in the environment.

Execution policy: a failed post_create is a non-fatal warning; a failed pre_remove aborts the removal unless --force (then it is a warning).

Structs§

CapturingHookRunner
A HookRunner that captures the hook’s stdout/stderr instead of inheriting the terminal. Used by the TUI’s background jobs (issue #46), which keep the alternate screen up and animate a spinner — inherited hook output would otherwise paint over the rendered UI. Behaviorally identical to RealHookRunner except the captured output is discarded.
HookContext
The context passed to a hook as WT_* environment variables.
RealHookRunner
The production HookRunner that spawns a shell and lets the hook inherit the terminal’s stdio (so output is visible to the user on the CLI paths, which suspend the TUI first).

Traits§

HookRunner
Runs hook commands. Abstracted so tests can inject a fake.

Functions§

run_post_create
Runs the post_create hook (spec §8). A non-zero exit (or run failure) is a non-fatal warning. no_hooks or an absent command is a no-op.
run_pre_remove
Runs the pre_remove hook (spec §8). A non-zero exit aborts the removal unless force is set, in which case it is reported as a warning and removal proceeds. no_hooks or an absent command is a no-op.