From fb4f9aa58ef67d192c7692dcfcb58c00a8fb7705 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 9 Mar 2026 17:09:08 -0700 Subject: [PATCH] Use repo initial branch in GitCore PR fetch integration test - Return `initialBranch` from test repo setup helper - Replace hardcoded `main` checkout/push/assertions with detected branch name --- apps/server/src/git/Layers/GitCore.test.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/server/src/git/Layers/GitCore.test.ts b/apps/server/src/git/Layers/GitCore.test.ts index 5aed70a78b560811c80c4a558873cb98f60d0a4e..e2af44b6da1e4b48fc17170e31df01de3fa76b7b 100644 --- a/apps/server/src/git/Layers/GitCore.test.ts +++ b/apps/server/src/git/Layers/GitCore.test.ts @@ -187,7 +187,7 @@ function pullGitBranch({ cwd }: { cwd: string }) { function initRepoWithCommit( cwd: string, ): Effect.Effect< - void, + { initialBranch: string }, GitCommandError | PlatformError.PlatformError, GitCore | GitService | FileSystem.FileSystem > { @@ -198,6 +198,8 @@ function initRepoWithCommit( yield* writeTextFile(path.join(cwd, "README.md"), "# test\n"); yield* git(cwd, ["add", "."]); yield* git(cwd, ["commit", "-m", "initial commit"]); + const initialBranch = yield* git(cwd, ["branch", "--show-current"]); + return { initialBranch }; }); } @@ -1207,18 +1209,18 @@ it.layer(TestLayer)("git integration", (it) => { it.effect("fetches a GitHub pull request ref into a local branch without checkout", () => Effect.gen(function* () { const tmp = yield* makeTmpDir(); - yield* initRepoWithCommit(tmp); + const { initialBranch } = yield* initRepoWithCommit(tmp); const remoteDir = yield* makeTmpDir("git-remote-"); yield* git(remoteDir, ["init", "--bare"]); yield* git(tmp, ["remote", "add", "origin", remoteDir]); - yield* git(tmp, ["push", "-u", "origin", "main"]); + yield* git(tmp, ["push", "-u", "origin", initialBranch]); yield* git(tmp, ["checkout", "-b", "feature/pr-fetch"]); yield* writeTextFile(path.join(tmp, "pr-fetch.txt"), "fetch me\n"); yield* git(tmp, ["add", "pr-fetch.txt"]); yield* git(tmp, ["commit", "-m", "Add PR fetch branch"]); yield* git(tmp, ["push", "-u", "origin", "feature/pr-fetch"]); yield* git(tmp, ["push", "origin", "HEAD:refs/pull/55/head"]); - yield* git(tmp, ["checkout", "main"]); + yield* git(tmp, ["checkout", initialBranch]); yield* fetchGitPullRequestBranch({ cwd: tmp, @@ -1229,7 +1231,7 @@ it.layer(TestLayer)("git integration", (it) => { const localBranches = yield* git(tmp, ["branch", "--list", "feature/pr-fetch"]); expect(localBranches).toContain("feature/pr-fetch"); const currentBranch = yield* git(tmp, ["branch", "--show-current"]); - expect(currentBranch).toBe("main"); + expect(currentBranch).toBe(initialBranch); }), ); }); -- 2.54.0