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

Function executeWorktreeRemoveHook

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

Source from the content-addressed store, hash-verified

4965 * hooks (plugin hooks + SDK callback hooks via registerHookCallbacks).
4966 */
4967export 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
5005function getHookDefinitionsForTelemetry(
5006 matchedHooks: MatchedHook[],

Callers 2

cleanupWorktreeFunction · 0.85
removeAgentWorktreeFunction · 0.85

Calls 5

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

Tested by

no test coverage detected