| ... | ... | @@ -187,7 +187,7 @@ function pullGitBranch({ cwd }: { cwd: string }) { |
| 187 | 187 | function initRepoWithCommit( |
| 188 | 188 | cwd: string, |
| 189 | 189 | ): Effect.Effect< |
| 190 | | void, |
| 190 | { initialBranch: string }, |
| 191 | 191 | GitCommandError | PlatformError.PlatformError, |
| 192 | 192 | GitCore | GitService | FileSystem.FileSystem |
| 193 | 193 | > { |
| ... | ... | @@ -198,6 +198,8 @@ function initRepoWithCommit( |
| 198 | 198 | yield* writeTextFile(path.join(cwd, "README.md"), "# test\n"); |
| 199 | 199 | yield* git(cwd, ["add", "."]); |
| 200 | 200 | yield* git(cwd, ["commit", "-m", "initial commit"]); |
| 201 | const initialBranch = yield* git(cwd, ["branch", "--show-current"]); |
| 202 | return { initialBranch }; |
| 201 | 203 | }); |
| 202 | 204 | } |
| 203 | 205 | |
| ... | ... | @@ -1207,18 +1209,18 @@ it.layer(TestLayer)("git integration", (it) => { |
| 1207 | 1209 | it.effect("fetches a GitHub pull request ref into a local branch without checkout", () => |
| 1208 | 1210 | Effect.gen(function* () { |
| 1209 | 1211 | const tmp = yield* makeTmpDir(); |
| 1210 | | yield* initRepoWithCommit(tmp); |
| 1212 | const { initialBranch } = yield* initRepoWithCommit(tmp); |
| 1211 | 1213 | const remoteDir = yield* makeTmpDir("git-remote-"); |
| 1212 | 1214 | yield* git(remoteDir, ["init", "--bare"]); |
| 1213 | 1215 | yield* git(tmp, ["remote", "add", "origin", remoteDir]); |
| 1214 | | yield* git(tmp, ["push", "-u", "origin", "main"]); |
| 1216 | yield* git(tmp, ["push", "-u", "origin", initialBranch]); |
| 1215 | 1217 | yield* git(tmp, ["checkout", "-b", "feature/pr-fetch"]); |
| 1216 | 1218 | yield* writeTextFile(path.join(tmp, "pr-fetch.txt"), "fetch me\n"); |
| 1217 | 1219 | yield* git(tmp, ["add", "pr-fetch.txt"]); |
| 1218 | 1220 | yield* git(tmp, ["commit", "-m", "Add PR fetch branch"]); |
| 1219 | 1221 | yield* git(tmp, ["push", "-u", "origin", "feature/pr-fetch"]); |
| 1220 | 1222 | yield* git(tmp, ["push", "origin", "HEAD:refs/pull/55/head"]); |
| 1221 | | yield* git(tmp, ["checkout", "main"]); |
| 1223 | yield* git(tmp, ["checkout", initialBranch]); |
| 1222 | 1224 | |
| 1223 | 1225 | yield* fetchGitPullRequestBranch({ |
| 1224 | 1226 | cwd: tmp, |
| ... | ... | @@ -1229,7 +1231,7 @@ it.layer(TestLayer)("git integration", (it) => { |
| 1229 | 1231 | const localBranches = yield* git(tmp, ["branch", "--list", "feature/pr-fetch"]); |
| 1230 | 1232 | expect(localBranches).toContain("feature/pr-fetch"); |
| 1231 | 1233 | const currentBranch = yield* git(tmp, ["branch", "--show-current"]); |
| 1232 | | expect(currentBranch).toBe("main"); |
| 1234 | expect(currentBranch).toBe(initialBranch); |
| 1233 | 1235 | }), |
| 1234 | 1236 | ); |
| 1235 | 1237 | }); |