Skip to content

Commit 0e21bf3

Browse files
AlbinoGeekclaude
andcommitted
test(merge): use shared addCommit helper instead of commitOnMain
Remove local commitOnMain function and import shared addCommit from test-harness. commitOnMain was identical in behavior to addCommit, just using different parameter names. Eliminates 4 lines of duplication. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent cf34893 commit 0e21bf3

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { join } from "node:path";
1212

1313
import { registerGitMergeTool } from "./git-merge-tool.js";
1414
import {
15+
addCommit,
1516
captureTool,
1617
cleanupTmpPaths,
1718
gitCmd,
@@ -40,12 +41,6 @@ function createBranchAhead(dir: string, branch: string, files: Record<string, st
4041
gitCmd(dir, "checkout", "main");
4142
}
4243

43-
function commitOnMain(dir: string, path: string, body: string, message: string): void {
44-
writeFileSync(join(dir, path), body);
45-
gitCmd(dir, "add", path);
46-
gitCmd(dir, "commit", "-m", message);
47-
}
48-
4944
// ---------------------------------------------------------------------------
5045
// Fast-forward path (most common: agent worktree ahead of main)
5146
// ---------------------------------------------------------------------------
@@ -103,7 +98,7 @@ describe("git_merge fast-forward", () => {
10398
const dir = makeRepo();
10499
// feature/a points at main, then main advances past it.
105100
gitCmd(dir, "branch", "feature/a", "HEAD");
106-
commitOnMain(dir, "extra.txt", "extra\n", "chore: advance main");
101+
addCommit(dir, "extra.txt", "extra\n", "chore: advance main");
107102

108103
const run = captureTool(registerGitMergeTool);
109104
const text = await run({
@@ -129,7 +124,7 @@ describe("git_merge strategy", () => {
129124
const dir = makeRepo();
130125
createBranchAhead(dir, "feature/a", { "a.txt": "A\n" });
131126
// advance main so feature/a is behind
132-
commitOnMain(dir, "m.txt", "M\n", "chore: main advance");
127+
addCommit(dir, "m.txt", "M\n", "chore: main advance");
133128

134129
const run = captureTool(registerGitMergeTool);
135130
const text = await run({
@@ -149,7 +144,7 @@ describe("git_merge strategy", () => {
149144
test("auto on diverged branches rebases then fast-forwards when clean", async () => {
150145
const dir = makeRepo();
151146
createBranchAhead(dir, "feature/a", { "a.txt": "A\n" });
152-
commitOnMain(dir, "m.txt", "M\n", "chore: main advance");
147+
addCommit(dir, "m.txt", "M\n", "chore: main advance");
153148

154149
const run = captureTool(registerGitMergeTool);
155150
const text = await run({
@@ -195,7 +190,7 @@ describe("git_merge strategy", () => {
195190
gitCmd(dir, "add", "shared.txt");
196191
gitCmd(dir, "commit", "-m", "feat: alpha");
197192
gitCmd(dir, "checkout", "main");
198-
commitOnMain(dir, "shared.txt", "beta\n", "chore: beta on main");
193+
addCommit(dir, "shared.txt", "beta\n", "chore: beta on main");
199194

200195
const run = captureTool(registerGitMergeTool);
201196
const text = await run({
@@ -220,7 +215,7 @@ describe("git_merge strategy", () => {
220215
gitCmd(dir, "add", "shared.txt");
221216
gitCmd(dir, "commit", "-m", "feat: alpha");
222217
gitCmd(dir, "checkout", "main");
223-
commitOnMain(dir, "shared.txt", "beta\n", "chore: beta");
218+
addCommit(dir, "shared.txt", "beta\n", "chore: beta");
224219

225220
const run = captureTool(registerGitMergeTool);
226221
const text = await run({

0 commit comments

Comments
 (0)