MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / executeWorktreeCreateHook

Function executeWorktreeCreateHook

source code/utils/hooks.ts:4930–4960  ·  view source on GitHub ↗
(
  name: string,
)

Source from the content-addressed store, hash-verified

4928 * Callers should check hasWorktreeCreateHook() before calling this.
4929 */
4930export async function executeWorktreeCreateHook(
4931 name: string,
4932): Promise<{ worktreePath: string }> {
4933 const hookInput = {
4934 ...createBaseHookInput(undefined),
4935 hook_event_name: 'WorktreeCreate' as const,
4936 name,
4937 }
4938
4939 const results = await executeHooksOutsideREPL({
4940 hookInput,
4941 timeoutMs: TOOL_HOOK_EXECUTION_TIMEOUT_MS,
4942 })
4943
4944 // Find the first successful result with non-empty output
4945 const successfulResult = results.find(
4946 r => r.succeeded && r.output.trim().length > 0,
4947 )
4948
4949 if (!successfulResult) {
4950 const failedOutputs = results
4951 .filter(r => !r.succeeded)
4952 .map(r => `${r.command}: ${r.output.trim() || 'no output'}`)
4953 throw new Error(
4954 `WorktreeCreate hook failed: ${failedOutputs.join('; ') || 'no successful output'}`,
4955 )
4956 }
4957
4958 const worktreePath = successfulResult.output.trim()
4959 return { worktreePath }
4960}
4961
4962/**
4963 * Execute WorktreeRemove hooks if configured.

Callers 3

createWorktreeForSessionFunction · 0.85
createAgentWorktreeFunction · 0.85
execIntoTmuxWorktreeFunction · 0.85

Calls 2

createBaseHookInputFunction · 0.85
executeHooksOutsideREPLFunction · 0.85

Tested by

no test coverage detected