fix(github): align PR source and review head origin (#10677)

* fix(github): align PR source and review head origin

* fix(github): pin number-based work item open to the repo source preference

Open-by-number and details still ran the upstream-first multi-candidate PR
probe, so a fork and its upstream sharing a PR number opened different PRs
than the list and start-point paths did once #10677 pinned those to origin.

Thread repo.issueSourcePreference through dispatchWorkItem, getWorkItemDetails,
getRepoWorkItem, and getRepoWorkItemDetails. getWorkItemByOwnerRepo is left
alone: explicit owner/repo already pins identity. auto/upstream/undefined keep
the multi-candidate probe.

Co-authored-by: Orca <help@stably.ai>

* test(github): enforce origin preference in review head origin resolution

The explicit origin preference must short-circuit before any identity probe, so no remote queries should occur. Add validation to reject unexpected remotes and tighten the test assertion to verify no remote get-url calls happen at all.

* fix(github): enforce origin preference in issue open-by-number lookup

listWorkItems and getWorkItem must share preference so origin/upstream
toggles cannot disagree. Explicit origin preference now fail-closes when
origin identity is unresolved (no bare-lookup fallback), matching the
PR candidate resolution rule.

---------

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinjing
2026-07-25 22:48:53 -07:00
committed by GitHub
co-authored by Orca
parent 8cb45318d7
commit 33bd676644
18 changed files with 654 additions and 69 deletions
+6 -9
View File
@@ -1,4 +1,4 @@
import type { GitHubPrStartPoint, GitPushTarget } from '../../shared/types'
import type { GitHubPrStartPoint, GitPushTarget, IssueSourcePreference } from '../../shared/types'
import { fetchCompareBaseRefWithLocalFallback } from '../git/compare-base-ref-fetch'
import {
isMissingRemoteRefGitError,
@@ -18,6 +18,7 @@ type ResolveGitHubPrStartPointArgs = {
headRefName?: string
baseRefName?: string
isCrossRepository?: boolean
issueSourcePreference?: IssueSourcePreference
connectionId?: string | null
localGitOptions?: { wslDistro?: string }
gitExec: GitExec
@@ -30,12 +31,6 @@ type ResolveGitHubPrStartPointArgs = {
type ResolveGitHubPrStartPointResult = GitHubPrStartPoint | { error: string }
function localGitOptionArgs(
options: { wslDistro?: string } | undefined
): [] | [{ wslDistro?: string }] {
return options && Object.keys(options).length > 0 ? [options] : []
}
export async function resolveGitHubPrStartPoint(
args: ResolveGitHubPrStartPointArgs
): Promise<ResolveGitHubPrStartPointResult> {
@@ -54,7 +49,8 @@ export async function resolveGitHubPrStartPoint(
args.repoPath,
args.prNumber,
args.connectionId ?? null,
...localGitOptionArgs(args.localGitOptions)
args.localGitOptions ?? {},
args.issueSourcePreference
)
pushTarget = resolved?.pushTarget
maintainerCanModify = resolved?.maintainerCanModify
@@ -71,7 +67,8 @@ export async function resolveGitHubPrStartPoint(
args.prNumber,
'pr',
args.connectionId ?? null,
...localGitOptionArgs(args.localGitOptions)
args.localGitOptions ?? {},
args.issueSourcePreference
)
if (!item || item.type !== 'pr') {
return { error: `PR #${args.prNumber} not found.` }