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

Function getGitRoot

browse/src/config.ts:32–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30 * Detect the git repository root, or null if not in a repo / git unavailable.
31 */
32export function getGitRoot(): string | null {
33 try {
34 const proc = Bun.spawnSync(['git', 'rev-parse', '--show-toplevel'], {
35 stdout: 'pipe',
36 stderr: 'pipe',
37 timeout: 2_000, // Don't hang if .git is broken
38 });
39 if (proc.exitCode !== 0) return null;
40 return proc.stdout.toString().trim() || null;
41 } catch {
42 return null;
43 }
44}
45
46/**
47 * Resolve all browse config paths.

Callers 3

config.test.tsFile · 0.90
resolveConfigFunction · 0.70
getRemoteSlugFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected