authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-02-09 14:24:22-08:00
committergravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-02-11 09:00:18-08:00
log647449069dc5348b1dffe406b71210d7c988b881
treea43e5cf50104b8f8eae2e80705474c88cdbe5135
parent6ce773ff1e865de0f1eb8f790f840ac0351d94ef

Add test for listGitBranches from worktree cwd

Verifies that querying branches from a worktree directory correctly reports the worktree's branch as current, while the main repo still shows its own branch — the assumption the BranchToolbar fix relies on. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

1 files changed, 30 insertions(+), 0 deletions(-)

apps/desktop/src/git.test.ts+30
......@@ -262,6 +262,36 @@ describe("git integration", () => {
262262 ).rejects.toThrow();
263263 });
264264
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
265295 it("removeGitWorktree cleans up the worktree", async () => {
266296 await using tmp = await makeTmpDir();
267297 await initRepoWithCommit(tmp.path);