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:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user