test(server): keep commit fixture authors independent of Git config (#6552)

Command-scoped user.name overrides the fixture repository configuration and breaks its author assertion. Supply the fixture author when creating commits and exercise the override with real Git.

Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
This commit is contained in:
paseo-bot[bot]
2026-10-11 05:46:39 +02:00
committed by GitHub
parent 7e66657bf0
commit 7f9b65d464
@@ -25,7 +25,10 @@ function git(args: string[], cwd?: string): void {
}
function commit(repoDir: string, message: string): void {
git(["-c", "commit.gpgsign=false", "commit", "-m", message], repoDir);
git(
["-c", "commit.gpgsign=false", "commit", "--author=Test User <test@test.com>", "-m", message],
repoDir,
);
}
function commitFile(repoDir: string, name: string, content: string, message: string): void {
@@ -92,6 +95,30 @@ function addBareRemote(repoDir: string, tempDir: string): string {
}
describe("listCheckoutCommits", () => {
it("keeps fixture authors independent of command-scoped Git configuration", async () => {
const overrides = {
GIT_CONFIG_COUNT: "1",
GIT_CONFIG_KEY_0: "user.name",
GIT_CONFIG_VALUE_0: "Other User",
};
const previous = Object.fromEntries(
Object.keys(overrides).map((key) => [key, process.env[key]]),
);
let repoDir: string;
try {
Object.assign(process.env, overrides);
({ repoDir } = initRepoOnMain());
} finally {
for (const [key, value] of Object.entries(previous)) {
if (value === undefined) delete process.env[key];
else process.env[key] = value;
}
}
const { commits } = await listCheckoutCommits({ cwd: repoDir });
expect(commits[0]?.authorName).toBe("Test User");
});
it("lists recent commits newest-first with on-remote flags and file stats", async () => {
const { repoDir, tempDir } = initRepoOnMain();
git(["checkout", "-b", "feature"], repoDir);