fix(prs): correct merged-PR, conflict and readiness semantics #39

Merged
dsh merged 1 commit from fix/qa-pr-semantics into master 2026-10-24 01:11:24 +00:00
Owner

What

Four PR-domain defects from the tester sweep.

#23 — gitea_pr_get on a merged PR

The formatter's data.merged clause hijacked every merged PR. Restricted the merge wording to gitea_pr_merge/gitea_auto_merge and added a gitea_pr_get formatter: #18 "title" [merged] by @dsh, head → base, URL, merge date and body (2 000-char cap).

#24 — pr_conflict_resolve says “Applied” without confirm

The clean early-return had no dryRun/applied; the formatter assumed applied. It now returns {clean:true, applied:false, dryRun: !confirm} and prints Conflict Resolution (dry-run): no conflicts to resolve; nothing to apply. “Applied” only follows a real confirm: true resolution.

#37 — conflict_analyze reports 0 conflicts for a missing ref

resolveRef() returned the ref name even when rev-parse failed. Unresolved base/head now return base branch not found: … / head branch not found: …; a merge-tree failure without conflict files is an error too. The formatter treats conflictsCount === 0 as clean, so a genuine clean pair says Conflict Analysis: Clean.

#38 — merge_readiness says “NOT ready” for a merged PR

checkMergeReadiness now short-circuits on pr.merged/merged_at and returns {merged:true, alreadyMerged:true, mergedAt, url} with no checks. autoMergeIfReady returns the same without calling mergePull. The formatter prints PR #18 is already merged at …; no merge needed.

Verification

  • test/pr-semantics.test.mjs: merged/open pr_get, merged readiness, auto-merge no-op, clean conflict-resolve dry run, missing base ref, clean analyze.
  • npm test 88/88, leak scan clean, node --check clean.
  • Live: gitea_pr_get 18 → full merged PR; gitea_merge_readiness 18 → “already merged”; conflict_analyze with no-such-base-branch → clear error; master/master → Clean; pr_conflict_resolve without confirm → dry-run no-op.

Closes #23, #24, #37, #38.

## What Four PR-domain defects from the tester sweep. ### #23 — `gitea_pr_get` on a merged PR The formatter's `data.merged` clause hijacked every merged PR. Restricted the merge wording to `gitea_pr_merge`/`gitea_auto_merge` and added a `gitea_pr_get` formatter: `#18 "title" [merged] by @dsh`, head → base, URL, merge date and body (2 000-char cap). ### #24 — `pr_conflict_resolve` says “Applied” without `confirm` The clean early-return had no `dryRun`/`applied`; the formatter assumed applied. It now returns `{clean:true, applied:false, dryRun: !confirm}` and prints `Conflict Resolution (dry-run): no conflicts to resolve; nothing to apply.` “Applied” only follows a real `confirm: true` resolution. ### #37 — `conflict_analyze` reports 0 conflicts for a missing ref `resolveRef()` returned the ref name even when `rev-parse` failed. Unresolved base/head now return `base branch not found: …` / `head branch not found: …`; a `merge-tree` failure without conflict files is an error too. The formatter treats `conflictsCount === 0` as clean, so a genuine clean pair says `Conflict Analysis: Clean.` ### #38 — `merge_readiness` says “NOT ready” for a merged PR `checkMergeReadiness` now short-circuits on `pr.merged`/`merged_at` and returns `{merged:true, alreadyMerged:true, mergedAt, url}` with no checks. `autoMergeIfReady` returns the same without calling `mergePull`. The formatter prints `PR #18 is already merged at …; no merge needed.` ## Verification - `test/pr-semantics.test.mjs`: merged/open `pr_get`, merged readiness, auto-merge no-op, clean conflict-resolve dry run, missing base ref, clean analyze. - `npm test` 88/88, leak scan clean, `node --check` clean. - Live: `gitea_pr_get 18` → full merged PR; `gitea_merge_readiness 18` → “already merged”; `conflict_analyze` with `no-such-base-branch` → clear error; `master`/`master` → Clean; `pr_conflict_resolve` without confirm → dry-run no-op. Closes #23, #24, #37, #38.
Render merged PRs as PRs, restrict the merge notice, treat clean conflict resolution as a dry-run no-op, error on unresolved refs instead of reporting 0 conflicts, and short-circuit merge readiness for already-merged PRs.
dsh merged commit 234cbd4f35 into master 2026-10-24 01:11:24 +00:00
Sign in to join this conversation.
No description provided.