MCPcopy
hub / github.com/codeaashu/claude-code / executeWorktreeCreateHook

Function executeWorktreeCreateHook

src/utils/hooks.ts:4928–4958  ·  view source on GitHub ↗
(
  name: string,
)

Source from the content-addressed store, hash-verified

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