ef4ec8dbe9
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
26 lines
847 B
TypeScript
26 lines
847 B
TypeScript
/**
|
|
* Cross-rung identity (F5, spec §6.3 fork c): `email` is git's own join key —
|
|
* forges already map email → account. Resolved from the workspace git config,
|
|
* cached per root, FAIL-OPEN: absence just omits the optional field and the
|
|
* sidecar stays valid (spec §6.9). vscode-free, so it is unit-testable.
|
|
*/
|
|
import { execFileSync } from "node:child_process";
|
|
|
|
const cache = new Map<string, string | undefined>();
|
|
|
|
export function gitUserEmail(rootDir: string): string | undefined {
|
|
if (!cache.has(rootDir)) {
|
|
try {
|
|
const out = execFileSync("git", ["config", "user.email"], {
|
|
cwd: rootDir,
|
|
encoding: "utf8",
|
|
stdio: ["ignore", "pipe", "ignore"],
|
|
}).trim();
|
|
cache.set(rootDir, out || undefined);
|
|
} catch {
|
|
cache.set(rootDir, undefined);
|
|
}
|
|
}
|
|
return cache.get(rootDir);
|
|
}
|