(args: string[], cwd: string)
| 25 | const MAX_ATTEMPTS = 5; |
| 26 | |
| 27 | async 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 | |
| 43 | async function resolveRepoRoot(basePath: string): Promise<string> { |
| 44 | const result = await runGit(['rev-parse', '--show-toplevel'], basePath); |
no outgoing calls
no test coverage detected