feat: display CI conflict details and improve merge-conflict UX (#234)

- Add PRConflictSummary type and derive conflict metadata (base ref,
  commits behind, conflicting files) via local git merge-tree
- Fix parseUnmergedEntry to use space-separated parsing (porcelain v2
  unmerged entries are not tab-separated)
- Enhance rebase detection by checking rebase-merge/ and rebase-apply/
  directories in addition to REBASE_HEAD
- Show conflicting files list and commits-behind count in ChecksPanel
- Disable merge button with tooltip when PR has conflicts
- Add operation banners (merge/rebase/cherry-pick) in SourceControl
  and WorktreeCard
- Reorder section list so unstaged changes appear above staged
- Extract conflict-summary, issues, and gh-utils into separate modules
- Add 10s timeout to git fetch in conflict summary derivation
- Fix test fixtures to match real porcelain v2 format
This commit is contained in:
Jinjing
2026-03-31 01:27:39 -07:00
committed by GitHub
parent 86ea7ad719
commit f2eb119c62
14 changed files with 749 additions and 283 deletions
+62
View File
@@ -0,0 +1,62 @@
import { execFile } from 'child_process'
import { promisify } from 'util'
export const execFileAsync = promisify(execFile)
// Concurrency limiter - max 4 parallel gh processes
const MAX_CONCURRENT = 4
let running = 0
const queue: (() => void)[] = []
export function acquire(): Promise<void> {
if (running < MAX_CONCURRENT) {
running++
return Promise.resolve()
}
return new Promise((resolve) =>
queue.push(() => {
running++
resolve()
})
)
}
export function release(): void {
running--
const next = queue.shift()
if (next) {
next()
}
}
// ── Owner/repo resolution for gh api --cache ──────────────────────────
const ownerRepoCache = new Map<string, { owner: string; repo: string } | null>()
/** @internal — exposed for tests only */
export function _resetOwnerRepoCache(): void {
ownerRepoCache.clear()
}
export async function getOwnerRepo(
repoPath: string
): Promise<{ owner: string; repo: string } | null> {
if (ownerRepoCache.has(repoPath)) {
return ownerRepoCache.get(repoPath)!
}
try {
const { stdout } = await execFileAsync('git', ['remote', 'get-url', 'origin'], {
cwd: repoPath,
encoding: 'utf-8'
})
const match = stdout.trim().match(/github\.com[:/]([^/]+)\/([^/.]+?)(?:\.git)?$/)
if (match) {
const result = { owner: match[1], repo: match[2] }
ownerRepoCache.set(repoPath, result)
return result
}
} catch {
// ignore — non-GitHub remote or no remote
}
ownerRepoCache.set(repoPath, null)
return null
}