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 @@
|
||||
import { describe, it, expect, beforeAll, afterAll } from "vitest";
|
||||
import * as fs from "node:fs";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { gitUserEmail } from "../src/identity";
|
||||
|
||||
let repo: string;
|
||||
|
||||
beforeAll(() => {
|
||||
repo = fs.mkdtempSync(path.join(os.tmpdir(), "cowriting-identity-"));
|
||||
execFileSync("git", ["init"], { cwd: repo, stdio: "ignore" });
|
||||
execFileSync("git", ["config", "user.email", "rung@example.org"], { cwd: repo });
|
||||
});
|
||||
afterAll(() => fs.rmSync(repo, { recursive: true, force: true }));
|
||||
|
||||
describe("gitUserEmail (F5 SLICE-2)", () => {
|
||||
it("reads the workspace git config user.email", () => {
|
||||
expect(gitUserEmail(repo)).toBe("rung@example.org");
|
||||
});
|
||||
|
||||
it("fails open (undefined) when git cannot run there", () => {
|
||||
expect(gitUserEmail("/nonexistent-dir-xyz")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user