Skip to content

Commit e59ce19

Browse files
AlbinoGeekclaude
andcommitted
test(parity): use shared gitCmd helper instead of direct execFileSync
Replace direct execFileSync calls with shared gitCmd helper from test-harness in gitInitMain and commitFile functions. gitCmd handles environment setup and encoding automatically, reducing code duplication and improving consistency. Remove unused execFileSync import. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 0e21bf3 commit e59ce19

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

src/server/git-parity-tool.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@
33
*/
44

55
import { afterEach, describe, expect, test } from "bun:test";
6-
import { execFileSync } from "node:child_process";
76
import { mkdirSync, writeFileSync } from "node:fs";
87
import { join } from "node:path";
98

109
import { registerGitParityTool } from "./git-parity-tool.js";
11-
import { captureTool, cleanupTmpPaths, mkTmpDir, writeTestGitConfig } from "./test-harness.js";
10+
import {
11+
captureTool,
12+
cleanupTmpPaths,
13+
gitCmd,
14+
mkTmpDir,
15+
writeTestGitConfig,
16+
} from "./test-harness.js";
1217

1318
afterEach(cleanupTmpPaths);
1419

1520
function gitInitMain(dir: string): void {
16-
execFileSync("git", ["init", "-b", "main"], { cwd: dir, stdio: "ignore" });
21+
gitCmd(dir, "init", "-b", "main");
1722
writeTestGitConfig(dir);
1823
}
1924

2025
function commitFile(dir: string, filename: string, content: string): string {
2126
writeFileSync(join(dir, filename), content);
22-
const env = {
23-
...process.env,
24-
GIT_AUTHOR_DATE: "2026-01-01T00:00:00Z",
25-
GIT_COMMITTER_DATE: "2026-01-01T00:00:00Z",
26-
};
27-
execFileSync("git", ["add", filename], { cwd: dir, env, stdio: "ignore" });
28-
execFileSync("git", ["commit", "-m", `add ${filename}`], { cwd: dir, env, stdio: "ignore" });
29-
return execFileSync("git", ["rev-parse", "HEAD"], { cwd: dir, encoding: "utf8" }).trim();
27+
gitCmd(dir, "add", filename);
28+
gitCmd(dir, "commit", "-m", `add ${filename}`);
29+
return gitCmd(dir, "rev-parse", "HEAD").trim();
3030
}
3131

3232
function makeParityWorkspace(prefix: string): { root: string; sha: string } {

0 commit comments

Comments
 (0)