fix(branch-picker): strip remote prefix when checking out remote branches

This commit is contained in:
xintaofei
2026-04-22 22:56:36 +08:00
parent 5ac9cee2ff
commit 7a03cfff36

View File

@@ -301,21 +301,28 @@ const BranchPicker = memo(function BranchPicker({
count: branchList.remote.length, count: branchList.remote.length,
})} })}
> >
{branchList.remote.map((b) => ( {branchList.remote.map((b) => {
const localName = b.replace(/^[^/]+\//, "")
return (
<CommandItem <CommandItem
key={`remote-${b}`} key={`remote-${b}`}
value={`remote ${b}`} value={`remote ${b}`}
onSelect={() => { onSelect={() => {
setOpen(false) setOpen(false)
void onCheckout(b) if (localName !== currentBranch)
void onCheckout(localName)
}} }}
> >
<GitBranch className="h-4 w-4 opacity-60" /> <GitBranch className="h-4 w-4 opacity-60" />
<span className="flex-1 truncate text-muted-foreground"> <span className="flex-1 truncate text-muted-foreground">
{b} {b}
</span> </span>
{localName === currentBranch && (
<Check className="h-4 w-4 shrink-0" />
)}
</CommandItem> </CommandItem>
))} )
})}
</CommandGroup> </CommandGroup>
)} )}
</> </>