Fix create PR visibility when upstream status is unknown

This commit is contained in:
Jinjing
2026-06-27 02:40:29 -07:00
parent 464c4562f9
commit cee5775f41
2 changed files with 16 additions and 1 deletions
@@ -616,6 +616,21 @@ describe('getHostedReviewCreationEligibility', () => {
})
})
it('rethrows review lookup failures when upstream status is unknown', async () => {
getHostedReviewForBranchMock.mockRejectedValueOnce(new Error('gh lookup failed'))
await expect(
getHostedReviewCreationEligibility({
repoPath: '/repo',
branch: 'feature/create-pr',
base: 'main',
hasUncommittedChanges: false,
ahead: 0,
behind: 0
})
).rejects.toThrow('gh lookup failed')
})
it('enables creation for clean, in-sync, authenticated GitHub feature branches', async () => {
await expect(
getHostedReviewCreationEligibility({
@@ -405,7 +405,7 @@ export async function getHostedReviewCreationEligibility(
branch !== 'HEAD' &&
supportsHostedReviewCreation(provider) &&
(!baseBranch || branch.toLowerCase() !== baseBranch.toLowerCase()) &&
(args.hasUncommittedChanges || args.hasUpstream !== true || (args.behind ?? 0) > 0)
(args.hasUncommittedChanges || args.hasUpstream === false || (args.behind ?? 0) > 0)
if (!canReturnLocalBlocker) {
throw error
}