mirror of
https://github.com/stablyai/orca.git
synced 2026-10-22 16:03:47 +00:00
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:
@@ -3530,6 +3530,44 @@ describe('getPRForBranch', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('pins explicit origin push-target lookup when upstream has the same PR number', async () => {
|
||||
getOwnerRepoMock.mockResolvedValue({ owner: 'fork', repo: 'orca' })
|
||||
resolvePRRepositoryCandidatesMock.mockResolvedValue({
|
||||
candidates: [
|
||||
{ owner: 'upstream', repo: 'orca' },
|
||||
{ owner: 'fork', repo: 'orca' }
|
||||
],
|
||||
headRepo: { owner: 'fork', repo: 'orca' }
|
||||
})
|
||||
ghExecFileAsyncMock.mockResolvedValueOnce({
|
||||
stdout: JSON.stringify({
|
||||
head: {
|
||||
ref: 'contributor/fix',
|
||||
repo: {
|
||||
full_name: 'contributor/orca',
|
||||
name: 'orca',
|
||||
clone_url: 'https://github.com/contributor/orca.git',
|
||||
ssh_url: 'git@github.com:contributor/orca.git',
|
||||
owner: { login: 'contributor' }
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
getRemoteUrlForRepoMock.mockResolvedValueOnce('git@github.com:fork/orca.git')
|
||||
|
||||
await getPullRequestPushTarget('/repo-root', 1738, null, {}, 'origin')
|
||||
|
||||
expect(resolvePRRepositoryCandidatesMock).not.toHaveBeenCalled()
|
||||
expect(ghExecFileAsyncMock).toHaveBeenCalledWith(['api', 'repos/fork/orca/pulls/1738'], {
|
||||
cwd: '/repo-root',
|
||||
host: 'github.com'
|
||||
})
|
||||
expect(ghExecFileAsyncMock).not.toHaveBeenCalledWith(
|
||||
['api', 'repos/upstream/orca/pulls/1738'],
|
||||
expect.anything()
|
||||
)
|
||||
})
|
||||
|
||||
it('surfaces maintainer_can_modify=false alongside a fork PR push target', async () => {
|
||||
getOwnerRepoMock.mockResolvedValueOnce({ owner: 'stablyai', repo: 'orca' })
|
||||
getOwnerRepoForRemoteMock.mockResolvedValueOnce({ owner: 'stablyai', repo: 'orca' })
|
||||
|
||||
Reference in New Issue
Block a user