MCPcopy
hub / github.com/garrytan/gstack / git

Function git

lib/worktree.ts:55–63  ·  view source on GitHub ↗

Run a git command and return stdout. Throws on failure unless tolerateFailure is set.

(args: string[], cwd: string, tolerateFailure = false)

Source from the content-addressed store, hash-verified

53
54/** Run a git command and return stdout. Throws on failure unless tolerateFailure is set. */
55function git(args: string[], cwd: string, tolerateFailure = false): string {
56 const result = spawnSync('git', args, { cwd, stdio: 'pipe', timeout: 30_000 });
57 const stdout = result.stdout?.toString().trim() ?? '';
58 const stderr = result.stderr?.toString().trim() ?? '';
59 if (result.status !== 0 && !tolerateFailure) {
60 throw new Error(`git ${args.join(' ')} failed (exit ${result.status}): ${stderr || stdout}`);
61 }
62 return stdout;
63}
64
65// --- Dedup index ---
66

Callers 5

constructorMethod · 0.70
createMethod · 0.70
harvestMethod · 0.70
cleanupMethod · 0.70
pruneStaleMethod · 0.70

Calls 1

spawnSyncFunction · 0.85

Tested by

no test coverage detected