fix(prs): gitea_conflict_analyze reports "0 conflicts" for a nonexistent base branch #37
Labels
No labels
area/dsh
area/forgejo
experiment
priority/later
priority/next
priority/now
type/bug
type/task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
dsh-plugins/dsh-gitea#37
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
gitea_conflict_analyzereports a clean/zero-conflict result for branches that do not exist. A typo inbase_branchis indistinguishable from a genuinely clean merge, which is unsafe for pre-merge checks.Repro
For a real, clean pair the formatter's clean branch should say
Conflict Analysis: Clean. ..., but even the validmaster/maincase earlier printed the same "0 conflicting file(s)" wording (main was deleted on 2026-10-23).Observed vs expected
base branch "no-such-base-branch" not found(or a failedgit merge-treereason), and for a genuine clean result theConflict Analysis: Clean.wording.Root cause
lib/conflict-assistant.js#analyzeMergeConflictsreturns a zero-file analysis when refs cannot be resolved instead of propagating a failure;data.cleanalso appears false for a zero-conflict result (the formatter took the non-clean branch in both valid and invalid cases). Thegitea_conflict_analyzeformatter only usesdata.clean.Proposed fix
Resolve/verify both refs before analysis and return
{ ok:false, error: 'branch not found: ...' }when either is missing; make the analysis setclean: truewhenconflictsCount === 0. Update the formatter to treatconflictsCount === 0as clean even without the flag. Tests: invalid ref → error; clean pair → "Clean"; conflicting pair → hunk list.Acceptance: a nonexistent base/head branch never reports "0 conflicts" as success.
Duplicate check
Searched
conflict(state all) — #24 coverspr_conflict_resolvewording; this is the analyze path.Layer
dsh-gitea plugin/tool (conflict assistant + formatter).
Fixed in
234cbd4(PR #39).analyzeMergeConflictsnow treats an unresolvablerev-parseas an error:base branch not found: no-such-base-branch/head branch not found: …. Amerge-treefailure with no conflict files is also an error instead of a zero-conflict success. The formatter treatsconflictsCount === 0as clean, so a genuine clean pair printsConflict Analysis: Clean.Live:
no-such-base-branch→ clear error;master/master→Conflict Analysis: Clean. Branches "master" and "master" merge cleanly….Tests:
test/pr-semantics.test.mjs.