feat: currentAuthor() carries git user.email — fail-open identity (F5 SLICE-2, #14)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ben Stull
2026-06-10 23:00:03 -07:00
parent 746071a585
commit ef4ec8dbe9
4 changed files with 56 additions and 2 deletions
+25
View File
@@ -0,0 +1,25 @@
/**
* 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);
}