MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / executeWorktreeRemoveHook

Function executeWorktreeRemoveHook

src/utils/hooks.ts:5135–5171  ·  view source on GitHub ↗
(
  worktreePath: string,
)

Source from the content-addressed store, hash-verified

5133 * hooks (plugin hooks + SDK callback hooks via registerHookCallbacks).
5134 */
5135export 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
5173function getHookDefinitionsForTelemetry(
5174 matchedHooks: MatchedHook[],

Callers 2

cleanupWorktreeFunction · 0.85
removeAgentWorktreeFunction · 0.85

Calls 5

getRegisteredHooksFunction · 0.85
createBaseHookInputFunction · 0.85
executeHooksOutsideREPLFunction · 0.85
logForDebuggingFunction · 0.70

Tested by

no test coverage detected