pub fn run_event(event: &str, cwd: &Path) -> Result<()>Expand description
Run the configured hook for event (one of "post_new", "pre_rm"),
resolving the hook command from the layered config rooted at the main
repo (resolved from cwd via git::get_main_repo_root, falling back to
cwd if that fails). The hook runs with cwd as its working directory.
No-op (returns Ok(())) when the event name is unknown or the hook is
unset. Hook is run as sh -c <cmd>. A non-zero exit propagates as
CwError::Other.
Caller policy — this function always returns Err on non-zero exit;
callers decide what that means:
pre_rmcallers treat the error as advisory: log a warning, then continue with removal (aligned with Claude Code’sWorktreeRemovehook, which cannot block cleanup).post_newcallers treat the error as blocking: propagate it as a non-zerogw newexit code and skip the AI tool launch.