MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / gitToplevelKey

Function gitToplevelKey

src/sync/git-hooks.ts:104–117  ·  view source on GitHub ↗

The work tree's top level (as a rootKey), or null when unknown.

(projectRoot: string)

Source from the content-addressed store, hash-verified

102
103/** The work tree's top level (as a {@link rootKey}), or null when unknown. */
104function gitToplevelKey(projectRoot: string): string | null {
105 try {
106 const out = execFileSync('git', ['rev-parse', '--show-toplevel'], {
107 cwd: projectRoot,
108 encoding: 'utf8',
109 stdio: ['ignore', 'pipe', 'ignore'],
110 windowsHide: true,
111 timeout: 5000, // same rationale as isGitRepo
112 }).trim();
113 return out ? rootKey(out) : null;
114 } catch {
115 return null;
116 }
117}
118
119function shellQuote(value: string): string {
120 return `'${value.replace(/'/g, `'\\''`)}'`;

Callers 1

ownerForFunction · 0.85

Calls 1

rootKeyFunction · 0.85

Tested by

no test coverage detected