From 647449069dc5348b1dffe406b71210d7c988b881 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 9 Feb 2026 14:24:22 -0800 Subject: [PATCH] Add test for listGitBranches from worktree cwd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- apps/desktop/src/git.test.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/apps/desktop/src/git.test.ts b/apps/desktop/src/git.test.ts index 104111b6cd4d9851db98a47f02cea326b040a864..0683069558069216ddbdfddfafdbb2c4e10877c5 100644 --- a/apps/desktop/src/git.test.ts +++ b/apps/desktop/src/git.test.ts @@ -262,6 +262,36 @@ describe("git integration", () => { ).rejects.toThrow(); }); + it("listGitBranches from worktree cwd reports worktree branch as current", async () => { + await using tmp = await makeTmpDir(); + await initRepoWithCommit(tmp.path); + + const wtPath = path.join(tmp.path, "wt-list-dir"); + const mainBranch = (await listGitBranches({ cwd: tmp.path })).branches.find( + (b) => b.current, + )!.name; + + await createGitWorktree({ + cwd: tmp.path, + branch: mainBranch, + newBranch: "wt-list", + path: wtPath, + }); + + // listGitBranches from the worktree should show wt-list as current + const wtBranches = await listGitBranches({ cwd: wtPath }); + expect(wtBranches.isRepo).toBe(true); + const wtCurrent = wtBranches.branches.find((b) => b.current); + expect(wtCurrent!.name).toBe("wt-list"); + + // Main repo should still show the original branch as current + const mainBranches = await listGitBranches({ cwd: tmp.path }); + const mainCurrent = mainBranches.branches.find((b) => b.current); + expect(mainCurrent!.name).toBe(mainBranch); + + await removeGitWorktree({ cwd: tmp.path, path: wtPath }); + }); + it("removeGitWorktree cleans up the worktree", async () => { await using tmp = await makeTmpDir(); await initRepoWithCommit(tmp.path); -- 2.54.0