| ... | @@ -262,6 +262,36 @@ describe("git integration", () => { | ... | @@ -262,6 +262,36 @@ describe("git integration", () => { |
| 262 | ).rejects.toThrow(); | 262 | ).rejects.toThrow(); |
| 263 | }); | 263 | }); |
| 264 | | 264 | |
| | 265 | it("listGitBranches from worktree cwd reports worktree branch as current", async () => { |
| | 266 | await using tmp = await makeTmpDir(); |
| | 267 | await initRepoWithCommit(tmp.path); |
| | 268 | |
| | 269 | const wtPath = path.join(tmp.path, "wt-list-dir"); |
| | 270 | const mainBranch = (await listGitBranches({ cwd: tmp.path })).branches.find( |
| | 271 | (b) => b.current, |
| | 272 | )!.name; |
| | 273 | |
| | 274 | await createGitWorktree({ |
| | 275 | cwd: tmp.path, |
| | 276 | branch: mainBranch, |
| | 277 | newBranch: "wt-list", |
| | 278 | path: wtPath, |
| | 279 | }); |
| | 280 | |
| | 281 | // listGitBranches from the worktree should show wt-list as current |
| | 282 | const wtBranches = await listGitBranches({ cwd: wtPath }); |
| | 283 | expect(wtBranches.isRepo).toBe(true); |
| | 284 | const wtCurrent = wtBranches.branches.find((b) => b.current); |
| | 285 | expect(wtCurrent!.name).toBe("wt-list"); |
| | 286 | |
| | 287 | // Main repo should still show the original branch as current |
| | 288 | const mainBranches = await listGitBranches({ cwd: tmp.path }); |
| | 289 | const mainCurrent = mainBranches.branches.find((b) => b.current); |
| | 290 | expect(mainCurrent!.name).toBe(mainBranch); |
| | 291 | |
| | 292 | await removeGitWorktree({ cwd: tmp.path, path: wtPath }); |
| | 293 | }); |
| | 294 | |
| 265 | it("removeGitWorktree cleans up the worktree", async () => { | 295 | it("removeGitWorktree cleans up the worktree", async () => { |
| 266 | await using tmp = await makeTmpDir(); | 296 | await using tmp = await makeTmpDir(); |
| 267 | await initRepoWithCommit(tmp.path); | 297 | await initRepoWithCommit(tmp.path); |