MCPcopy Create free account
hub / github.com/tiann/hapi / runGit

Function runGit

cli/src/runner/worktree.ts:27–41  ·  view source on GitHub ↗
(args: string[], cwd: string)

Source from the content-addressed store, hash-verified

25const MAX_ATTEMPTS = 5;
26
27async function runGit(args: string[], cwd: string): Promise<{ stdout: string; stderr: string }> {
28 try {
29 const result = await execFileAsync('git', args, { cwd });
30 return {
31 stdout: result.stdout ? result.stdout.toString() : '',
32 stderr: result.stderr ? result.stderr.toString() : ''
33 };
34 } catch (error) {
35 const execError = error as NodeJS.ErrnoException & { stdout?: string; stderr?: string };
36 const stderr = execError.stderr ? execError.stderr.toString() : '';
37 const stdout = execError.stdout ? execError.stdout.toString() : '';
38 const message = stderr.trim() || stdout.trim() || execError.message || 'Git command failed';
39 throw new Error(message);
40 }
41}
42
43async function resolveRepoRoot(basePath: string): Promise<string> {
44 const result = await runGit(['rev-parse', '--show-toplevel'], basePath);

Callers 4

resolveRepoRootFunction · 0.70
branchExistsFunction · 0.70
createWorktreeFunction · 0.70
removeWorktreeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected