( worktreePath: string, )
| 5064 | * hooks (plugin hooks + SDK callback hooks via registerHookCallbacks). |
| 5065 | */ |
| 5066 | export async function executeWorktreeRemoveHook( |
| 5067 | worktreePath: string, |
| 5068 | ): Promise<boolean> { |
| 5069 | const snapshotHooks = getHooksConfigFromSnapshot()?.['WorktreeRemove'] |
| 5070 | const registeredHooks = getRegisteredHooks()?.['WorktreeRemove'] |
| 5071 | const hasSnapshotHooks = snapshotHooks && snapshotHooks.length > 0 |
| 5072 | const hasRegisteredHooks = registeredHooks && registeredHooks.length > 0 |
| 5073 | if (!hasSnapshotHooks && !hasRegisteredHooks) { |
| 5074 | return false |
| 5075 | } |
| 5076 | |
| 5077 | const hookInput = { |
| 5078 | ...createBaseHookInput(undefined), |
| 5079 | hook_event_name: 'WorktreeRemove' as const, |
| 5080 | worktree_path: worktreePath, |
| 5081 | } |
| 5082 | |
| 5083 | const results = await executeHooksOutsideREPL({ |
| 5084 | hookInput, |
| 5085 | timeoutMs: TOOL_HOOK_EXECUTION_TIMEOUT_MS, |
| 5086 | }) |
| 5087 | |
| 5088 | if (results.length === 0) { |
| 5089 | return false |
| 5090 | } |
| 5091 | |
| 5092 | for (const result of results) { |
| 5093 | if (!result.succeeded) { |
| 5094 | logForDebugging( |
| 5095 | `WorktreeRemove hook failed [${result.command}]: ${result.output.trim()}`, |
| 5096 | { level: 'error' }, |
| 5097 | ) |
| 5098 | } |
| 5099 | } |
| 5100 | |
| 5101 | return true |
| 5102 | } |
| 5103 | |
| 5104 | function getHookDefinitionsForTelemetry( |
| 5105 | matchedHooks: MatchedHook[], |
no test coverage detected