fix(server): new worktrees fetch their base branch's own remote #21032
Mergedstbenjam(GitHub profile, opens in a new tab)merged 18 commits into
main fromrefs/pull/21032/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/vcs/GitVcsDriverCore.ts line 3912Resolvedby stbenjam(GitHub profile, opens in a new tab)@@ -3775,0 +3783,21 @@3783+ "for-each-ref",3784+ "--format=%(refname)\t%(upstream:remotename)\t%(upstream:remoteref)",3785+ `refs/heads/${input.refName}`,3786+ ]).pipe(3787+ Effect.map((stdout) =>3788+ stdout3789+ .split("\n")3790+ .map((line) => line.split("\t"))3791+ .find(([refName]) => refName === `refs/heads/${input.refName}`),3792+ ),3793+ );3794+ let target: { remoteName: string; branchName: string } | null;3795+ if (localBranch) {3796+ // A remote of "." tracks another local branch; it is not a remote name.3797+ const [, remoteName = "", merge = ""] = localBranch;3798+ target =3799+ remoteNames.includes(remoteName) && merge.startsWith("refs/heads/")3800+ ? { remoteName, branchName: merge.slice("refs/heads/".length) }3801+ : null;3802+ } else {3803+ target = parseRemoteRefWithRemoteNames(input.refName, remoteNames);
- apps/server/src/vcs/GitVcsDriverCore.ts line 3937Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -3775,0 +3803,21 @@3803+ remoteNames.includes(remoteName) && merge.startsWith("refs/heads/")3804+ ? { remoteName, branchName: merge.slice("refs/heads/".length) }3805+ : null;3806+ } else {3807+ target = parseRemoteRefWithRemoteNames(input.refName, remoteNames);3808+ }3809+ const { remoteName, branchName } = target ?? {3810+ remoteName: "origin",3811+ branchName: input.refName,3812+ };3813+ if (!remoteNames.includes(remoteName)) return null;3814+3815+ const remoteRefName = `${remoteName}/${branchName}`;3816+ yield* fetchRemote({ cwd: input.cwd, remoteName, refName: remoteRefName });3817+ const resolved = yield* executeGit(3818+ "GitVcsDriver.fetchWorktreeBaseCommit",3819+ input.cwd,3820+ ["rev-parse", "--verify", "--quiet", `refs/remotes/${remoteRefName}^{commit}`],3821+ { allowNonZeroExit: true },3822+ );3823+ return resolved.exitCode === 0 ? { commitSha: resolved.stdout.trim(), remoteRefName } : null;apps/web/src/components/BranchPicker.tsx lines 245 to 246OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -230,17 +230,17 @@230230 <span className="flex min-w-0 items-center gap-1.5 font-medium text-muted-foreground">231231 <RefreshIcon aria-hidden="true" className="size-3 shrink-0" />232- <span className="truncate">Start from origin</span>232+ <span className="truncate">Start from remote</span>233233 </span>234234 <Switch235235 id={startFromOriginSwitchId}236236 checked={originControl.checked}237237 size="sm"238- aria-label="Start worktree from origin"238+ aria-label="Start worktree from remote"239239 onCheckedChange={(checked) => originControl.onCheckedChange(Boolean(checked))}240240 />241241 </label>242242 }243243 />244244 <TooltipPopup side="top" className="max-w-72 whitespace-normal">245- Creates the worktree from the latest matching branch on origin instead of your local246- branch.245+ Creates the worktree from the latest fetched commit of the base branch's remote246+ instead of your local branch.
juliusmarminge assignedjuliusmarminge
juliusmarminge merged this673c5e3
juliusmarminge closed this
Sign in to join this conversation.




macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed