fix(github): load PR details on fork checkouts by preferring upstream (#9384)
On a fork checkout (origin=fork, upstream=parent) PR details failed to load because getOwnerRepo() resolved only the origin remote while GitHub PRs live on the upstream parent. Make getOwnerRepo() prefer upstream (mirroring getIssueOwnerRepo), and pin the call sites that genuinely need the checkout's own origin identity (getRepoSlug, getRepoUpstream, createGitHubPullRequest, resolvePrWorkItemSource) to the origin-only primitive. Lands the fix community-identified in #7332 and hardened in #7513. Closes #7331 Co-authored-by: fsdwen <1214772+fsdwen@users.noreply.github.com> Co-authored-by: brennanb2025 <79079362+brennanb2025@users.noreply.github.com>
This commit is contained in:
co-authored by
fsdwen
brennanb2025
parent
403d681d83
commit
4930c87219
@@ -98,7 +98,14 @@ describe('listWorkItems', () => {
|
||||
source: await getIssueOwnerRepoMock(),
|
||||
fellBack: false
|
||||
}))
|
||||
getOwnerRepoForRemoteMock.mockResolvedValue(null)
|
||||
// Why: since #7331 `resolvePrWorkItemSource` fetches origin through
|
||||
// `getOwnerRepoForRemote` (getOwnerRepo became upstream-first). Delegate
|
||||
// the origin probe to `getOwnerRepoMock` so existing tests keep defining
|
||||
// the PR-side origin through it; default upstream to null.
|
||||
getOwnerRepoForRemoteMock.mockImplementation(
|
||||
async (repoPath: string, remoteName: string, connectionId?: string | null, opts = {}) =>
|
||||
remoteName === 'origin' ? getOwnerRepoMock(repoPath, connectionId, opts) : null
|
||||
)
|
||||
_resetOwnerRepoCache()
|
||||
_resetMergeQueueCacheForTests()
|
||||
_resetGhCwdRepoNegativeCache()
|
||||
@@ -262,7 +269,10 @@ describe('listWorkItems', () => {
|
||||
fellBack: false
|
||||
})
|
||||
getOwnerRepoMock.mockResolvedValue({ owner: 'acme', repo: 'widgets' })
|
||||
getOwnerRepoForRemoteMock.mockResolvedValue(null)
|
||||
getOwnerRepoForRemoteMock.mockImplementation(
|
||||
async (repoPath: string, remoteName: string, connectionId?: string | null, opts = {}) =>
|
||||
remoteName === 'origin' ? getOwnerRepoMock(repoPath, connectionId, opts) : null
|
||||
)
|
||||
ghExecFileAsyncMock.mockResolvedValue({ stdout: '[]' })
|
||||
|
||||
await listWorkItems(
|
||||
@@ -282,7 +292,12 @@ describe('listWorkItems', () => {
|
||||
null,
|
||||
localGitOptions
|
||||
)
|
||||
expect(getOwnerRepoMock).toHaveBeenCalledWith('/repo-root', null, localGitOptions)
|
||||
expect(getOwnerRepoForRemoteMock).toHaveBeenCalledWith(
|
||||
'/repo-root',
|
||||
'origin',
|
||||
null,
|
||||
localGitOptions
|
||||
)
|
||||
expect(getOwnerRepoForRemoteMock).toHaveBeenCalledWith(
|
||||
'/repo-root',
|
||||
'upstream',
|
||||
|
||||
Reference in New Issue
Block a user