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