From 9aa0718cf91f8a4c641452d2a1748bcbc9a8ef32 Mon Sep 17 00:00:00 2001 From: LU XIANGRUI <1078666705@qq.com> Date: Sun, 29 Nov 2026 00:04:41 +0900 Subject: [PATCH] fix(github): keep a new pull request's head on the base repository's host (#6746) Follow-up to #6742. The new pull request form's head repository picker keyed its options by owner/name, so same-named repositories on an Enterprise server and on github.com could not both be picked, and it offered remotes on another host. It now lists only remotes on the base repository's host, keyed by host/owner/name, and the default head ignores a tracked remote on another host. A selection saved before #6742 (no host) now resolves to the origin remote's repository when that is one of the matches, instead of depending on remote order. Co-authored-by: wildcatDownstairs <26499420+wildcatDownstairs@users.noreply.github.com> --- .../github/create/DirectionSelector.tsx | 17 ++++++---- src/features/github/create/create.test.ts | 18 ++++++++++ src/features/github/create/model.ts | 9 ++++- src/features/github/data/data.test.ts | 7 ++++ src/features/github/data/repository.test.ts | 33 +++++++++++++++++-- src/features/github/data/repository.ts | 6 +++- 6 files changed, 79 insertions(+), 11 deletions(-) diff --git a/src/features/github/create/DirectionSelector.tsx b/src/features/github/create/DirectionSelector.tsx index 490dbbcbf..dc839bd5a 100644 --- a/src/features/github/create/DirectionSelector.tsx +++ b/src/features/github/create/DirectionSelector.tsx @@ -7,11 +7,12 @@ import { useMemo, useState, type KeyboardEvent } from "react"; import { HighlightedText, Icon, List, Popup, SearchField, Select, T, fuzzyMatch, listNavigate } from "@/ui"; import { useTx } from "@/platform/i18n"; -import { NO_REMOTES, nameWithOwner, sameRepository, useGhRepository, type GHRemote } from "../data/repository"; +import { NO_REMOTES, nameWithOwner, repositoryKey, useGhRepository, type GHRemote } from "../data/repository"; import { ChooserPopup } from "../ui/ChooserPopup"; import { baseText, headBranchName, + headRepositories, headText, localBranchesOf, remoteBranchesOf, @@ -78,6 +79,7 @@ export function DirectionSelector() { {open?.which === "head" && ( setOpen(null)} /> @@ -89,9 +91,10 @@ export function DirectionSelector() { type HeadRow = { section: string } | { branch: HeadBranch; text: string; match: number[] | null }; /** The head: the repository (several GitHub remotes only), then its branches, local first. */ -function HeadPopup(props: { anchor: HTMLElement; initialRepo: GHRemote; onClose: () => void }) { +function HeadPopup(props: { anchor: HTMLElement; base: GHRemote; initialRepo: GHRemote; onClose: () => void }) { const tx = useTx(); - const remotes = useGhRepository((s) => s.connection?.remotes ?? NO_REMOTES); + const connected = useGhRepository((s) => s.connection?.remotes ?? NO_REMOTES); + const remotes = useMemo(() => headRepositories(connected, props.base), [connected, props.base]); const branches = useCreatePr((s) => s.branches); const current = useCreatePr((s) => s.direction?.headBranch ?? null); const [repo, setRepo] = useState(props.initialRepo); @@ -144,11 +147,11 @@ function HeadPopup(props: { anchor: HTMLElement; initialRepo: GHRemote; onClose: Repository: