feat: surface merge conflict warning in checks panel (#206)

This commit is contained in:
Jinjing
2026-03-29 16:27:18 -07:00
committed by GitHub
parent 193c6b96d1
commit e2bb60339f
6 changed files with 157 additions and 113 deletions
+8 -4
View File
@@ -32,7 +32,8 @@ describe('getPRForBranch', () => {
url: 'https://github.com/acme/widgets/pull/42',
statusCheckRollup: [],
updatedAt: '2026-03-28T00:00:00Z',
isDraft: false
isDraft: false,
mergeable: 'MERGEABLE'
}
])
})
@@ -58,12 +59,13 @@ describe('getPRForBranch', () => {
'--limit',
'1',
'--json',
'number,title,state,url,statusCheckRollup,updatedAt,isDraft'
'number,title,state,url,statusCheckRollup,updatedAt,isDraft,mergeable'
],
{ cwd: '/repo-root', encoding: 'utf-8' }
)
expect(pr?.number).toBe(42)
expect(pr?.state).toBe('open')
expect(pr?.mergeable).toBe('MERGEABLE')
})
it('falls back to gh pr view when the remote cannot be resolved to GitHub', async () => {
@@ -75,7 +77,8 @@ describe('getPRForBranch', () => {
url: 'https://example.com/pr/7',
statusCheckRollup: [],
updatedAt: '2026-03-28T00:00:00Z',
isDraft: true
isDraft: true,
mergeable: 'CONFLICTING'
})
})
@@ -89,12 +92,13 @@ describe('getPRForBranch', () => {
'view',
'feature/test',
'--json',
'number,title,state,url,statusCheckRollup,updatedAt,isDraft'
'number,title,state,url,statusCheckRollup,updatedAt,isDraft,mergeable'
],
{ cwd: '/non-github-repo', encoding: 'utf-8' }
)
expect(pr?.number).toBe(7)
expect(pr?.state).toBe('draft')
expect(pr?.mergeable).toBe('CONFLICTING')
})
it('returns null for empty branch (e.g. during rebase with detached HEAD)', async () => {
+6 -4
View File
@@ -1,6 +1,6 @@
import { execFile } from 'child_process'
import { promisify } from 'util'
import type { PRInfo, IssueInfo, PRCheckDetail } from '../../shared/types'
import type { PRInfo, PRMergeableState, IssueInfo, PRCheckDetail } from '../../shared/types'
import {
mapCheckRunRESTStatus,
mapCheckRunRESTConclusion,
@@ -94,6 +94,7 @@ export async function getPRForBranch(repoPath: string, branch: string): Promise<
statusCheckRollup: unknown[]
updatedAt: string
isDraft?: boolean
mergeable: string
} | null = null
if (ownerRepo) {
@@ -111,7 +112,7 @@ export async function getPRForBranch(repoPath: string, branch: string): Promise<
'--limit',
'1',
'--json',
'number,title,state,url,statusCheckRollup,updatedAt,isDraft'
'number,title,state,url,statusCheckRollup,updatedAt,isDraft,mergeable'
],
{
cwd: repoPath,
@@ -128,7 +129,7 @@ export async function getPRForBranch(repoPath: string, branch: string): Promise<
'view',
branchName,
'--json',
'number,title,state,url,statusCheckRollup,updatedAt,isDraft'
'number,title,state,url,statusCheckRollup,updatedAt,isDraft,mergeable'
],
{
cwd: repoPath,
@@ -148,7 +149,8 @@ export async function getPRForBranch(repoPath: string, branch: string): Promise<
state: mapPRState(data.state, data.isDraft),
url: data.url,
checksStatus: deriveCheckStatus(data.statusCheckRollup),
updatedAt: data.updatedAt
updatedAt: data.updatedAt,
mergeable: (data.mergeable as PRMergeableState) ?? 'UNKNOWN'
}
} catch {
return null