Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions apps/web/src/components/BranchToolbar.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ describe("resolveBranchSelectionTarget", () => {
activeProjectCwd: "/repo",
activeWorktreePath: "/repo/.t3/worktrees/feature-a",
refName: {
isDefault: false,
worktreePath: "/repo/.t3/worktrees/feature-b",
},
}),
Expand All @@ -315,7 +314,6 @@ describe("resolveBranchSelectionTarget", () => {
activeProjectCwd: "/repo",
activeWorktreePath: "/repo/.t3/worktrees/feature-a",
refName: {
isDefault: true,
worktreePath: "/repo",
},
}),
Expand All @@ -326,30 +324,12 @@ describe("resolveBranchSelectionTarget", () => {
});
});

it("checks out the default ref in the main repo when leaving a secondary worktree", () => {
it("keeps checkout in the current worktree when the selected ref has no existing worktree", () => {
expect(
resolveBranchSelectionTarget({
activeProjectCwd: "/repo",
activeWorktreePath: "/repo/.t3/worktrees/feature-a",
refName: {
isDefault: true,
worktreePath: null,
},
}),
).toEqual({
checkoutCwd: "/repo",
nextWorktreePath: null,
reuseExistingWorktree: false,
});
});

it("keeps checkout in the current worktree for non-default refs", () => {
expect(
resolveBranchSelectionTarget({
activeProjectCwd: "/repo",
activeWorktreePath: "/repo/.t3/worktrees/feature-a",
refName: {
isDefault: false,
worktreePath: null,
},
}),
Expand Down
9 changes: 3 additions & 6 deletions apps/web/src/components/BranchToolbar.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function resolveBranchToolbarValue(input: {
export function resolveBranchSelectionTarget(input: {
activeProjectCwd: string;
activeWorktreePath: string | null;
refName: Pick<VcsRef, "isDefault" | "worktreePath">;
refName: Pick<VcsRef, "worktreePath">;
}): {
checkoutCwd: string;
nextWorktreePath: string | null;
Expand All @@ -116,12 +116,9 @@ export function resolveBranchSelectionTarget(input: {
};
}

const nextWorktreePath =
Comment thread
cursor[bot] marked this conversation as resolved.
activeWorktreePath !== null && refName.isDefault ? null : activeWorktreePath;

return {
checkoutCwd: nextWorktreePath ?? activeProjectCwd,
nextWorktreePath,
checkoutCwd: activeWorktreePath ?? activeProjectCwd,
nextWorktreePath: activeWorktreePath,
reuseExistingWorktree: false,
};
}
Expand Down
Loading