( worktreePath: string, )
| 5133 | * hooks (plugin hooks + SDK callback hooks via registerHookCallbacks). |
| 5134 | */ |
| 5135 | export async function executeWorktreeRemoveHook( |
| 5136 | worktreePath: string, |
| 5137 | ): Promise<boolean> { |
| 5138 | const snapshotHooks = getHooksConfigFromSnapshot()?.['WorktreeRemove'] |
| 5139 | const registeredHooks = getRegisteredHooks()?.['WorktreeRemove'] |
| 5140 | const hasSnapshotHooks = snapshotHooks && snapshotHooks.length > 0 |
| 5141 | const hasRegisteredHooks = registeredHooks && registeredHooks.length > 0 |
| 5142 | if (!hasSnapshotHooks && !hasRegisteredHooks) { |
| 5143 | return false |
| 5144 | } |
| 5145 | |
| 5146 | const hookInput = { |
| 5147 | ...createBaseHookInput(undefined), |
| 5148 | hook_event_name: 'WorktreeRemove' as const, |
| 5149 | worktree_path: worktreePath, |
| 5150 | } |
| 5151 | |
| 5152 | const results = await executeHooksOutsideREPL({ |
| 5153 | hookInput, |
| 5154 | timeoutMs: TOOL_HOOK_EXECUTION_TIMEOUT_MS, |
| 5155 | }) |
| 5156 | |
| 5157 | if (results.length === 0) { |
| 5158 | return false |
| 5159 | } |
| 5160 | |
| 5161 | for (const result of results) { |
| 5162 | if (!result.succeeded) { |
| 5163 | logForDebugging( |
| 5164 | `WorktreeRemove hook failed [${result.command}]: ${result.output.trim()}`, |
| 5165 | { level: 'error' }, |
| 5166 | ) |
| 5167 | } |
| 5168 | } |
| 5169 | |
| 5170 | return true |
| 5171 | } |
| 5172 | |
| 5173 | function getHookDefinitionsForTelemetry( |
| 5174 | matchedHooks: MatchedHook[], |
no test coverage detected