( worktreePath: string, )
| 4969 | * hooks (plugin hooks + SDK callback hooks via registerHookCallbacks). |
| 4970 | */ |
| 4971 | export async function executeWorktreeRemoveHook( |
| 4972 | worktreePath: string, |
| 4973 | ): Promise<boolean> { |
| 4974 | const snapshotHooks = getHooksConfigFromSnapshot()?.['WorktreeRemove'] |
| 4975 | const registeredHooks = getRegisteredHooks()?.['WorktreeRemove'] |
| 4976 | const hasSnapshotHooks = snapshotHooks && snapshotHooks.length > 0 |
| 4977 | const hasRegisteredHooks = registeredHooks && registeredHooks.length > 0 |
| 4978 | if (!hasSnapshotHooks && !hasRegisteredHooks) { |
| 4979 | return false |
| 4980 | } |
| 4981 | |
| 4982 | const hookInput = { |
| 4983 | ...createBaseHookInput(undefined), |
| 4984 | hook_event_name: 'WorktreeRemove' as const, |
| 4985 | worktree_path: worktreePath, |
| 4986 | } |
| 4987 | |
| 4988 | const results = await executeHooksOutsideREPL({ |
| 4989 | hookInput, |
| 4990 | timeoutMs: TOOL_HOOK_EXECUTION_TIMEOUT_MS, |
| 4991 | }) |
| 4992 | |
| 4993 | if (results.length === 0) { |
| 4994 | return false |
| 4995 | } |
| 4996 | |
| 4997 | for (const result of results) { |
| 4998 | if (!result.succeeded) { |
| 4999 | logForDebugging( |
| 5000 | `WorktreeRemove hook failed [${result.command}]: ${result.output.trim()}`, |
| 5001 | { level: 'error' }, |
| 5002 | ) |
| 5003 | } |
| 5004 | } |
| 5005 | |
| 5006 | return true |
| 5007 | } |
| 5008 | |
| 5009 | function getHookDefinitionsForTelemetry( |
| 5010 | matchedHooks: MatchedHook[], |
no test coverage detected