Handle clean local merges when hosting provider reports conflicts (#5942)

When the hosting provider (GitHub) reports conflicts but a local merge
simulation is clean, we now mark the conflict summary as locally clean.

This state is surfaced in both the desktop and mobile sidebars with a
clear explanation and a copyable set of commands to trigger a remote
mergeability recalculation via an empty commit and push.
This commit is contained in:
Jinjing
2026-06-20 17:08:58 -07:00
committed by GitHub
parent 8a4f10b35c
commit 16347ab799
15 changed files with 413 additions and 23 deletions
+36
View File
@@ -1632,6 +1632,42 @@ describe('getPRForBranch', () => {
expect(pr?.conflictSummary).toBeUndefined()
})
it('marks the conflict summary as locally clean when GitHub reports dirty but merge-tree has no conflicted files', async () => {
getOwnerRepoMock.mockResolvedValueOnce({ owner: 'acme', repo: 'widgets' })
ghExecFileAsyncMock.mockResolvedValueOnce({
stdout: JSON.stringify([
{
number: 42,
title: 'Fix PR discovery',
state: 'open',
html_url: 'https://github.com/acme/widgets/pull/42',
updated_at: '2026-06-20T22:16:43Z',
draft: false,
mergeable_state: 'dirty',
base: { ref: 'main', sha: 'base-oid' },
head: { ref: 'feature/test', sha: 'head-oid' }
}
])
})
gitExecFileAsyncMock
.mockResolvedValueOnce({ stdout: '' })
.mockResolvedValueOnce({ stdout: 'latest-base-oid\n' })
.mockResolvedValueOnce({ stdout: 'merge-base-oid\n' })
.mockResolvedValueOnce({ stdout: '1\n' })
.mockResolvedValueOnce({ stdout: 'result-tree-oid\u0000' })
const pr = await getPRForBranch('/repo-root', 'feature/test')
expect(pr?.mergeable).toBe('CONFLICTING')
expect(pr?.conflictSummary).toEqual({
baseRef: 'main',
baseCommit: 'latest-',
commitsBehind: 1,
files: [],
localMergeState: 'clean'
})
})
it('falls back to GitHub baseRefOid when fetching or resolving the base ref fails', async () => {
getOwnerRepoMock.mockResolvedValueOnce({ owner: 'acme', repo: 'widgets' })
ghExecFileAsyncMock.mockResolvedValueOnce({
+2 -1
View File
@@ -37,7 +37,8 @@ export async function getPRConflictSummary(
baseRef: baseRefName,
baseCommit: latestBaseOid.slice(0, 7),
commitsBehind,
files
files,
...(files.length === 0 ? { localMergeState: 'clean' as const } : {})
}
} catch {
return undefined