Report the specific reason a PR merge was rejected #162
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/159-merge-reason"
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?
Closes #159, #160.
fj pr mergereturned a bare405 Method Not Allowed(sometimes500) for every reason a PR could not merge: conflicts, a disabled merge style, failing required checks, missing approvals, an out-of-date branch, an already-merged PR. The opaque status is indistinguishable across causes and cost real debugging time during the 2026-06-15 drain.What changed:
pull::mergeandpull::update_branchused reqwest'serror_for_status, which drops the response body. They now go through a newClient::sendthat runs the sameensure_successpath as the JSON helpers, so Forgejo's own error message survives instead of collapsing to the status line.cli::pr_merge_check): on a merge failure the CLI inspects the PR's mergeability and prints one specific, actionable reason. It reads the PR state/mergeable/draft flags, the repo's allowed merge styles, branch protection (required approvals, required status checks, block-on-outdated), reviews, and the head commit status, then reports the most fundamental blocker. Gathering is best-effort: a permission error on branch protection (common for non-admins) degrades to unknown rather than masking the diagnosis. When nothing specific is found it falls back to the now-surfaced raw message.fj pr viewandfj pr checksgained a cheapMergeable:line (no extra API calls).Tests: 11 unit tests over the pure reason-picker plus 5 wiremock tests (405 message passthrough, and end-to-end disabled-style / conflict / failing-check / missing-approvals diagnosis). Full suite green, clippy -D warnings clean.
6af87fa46406ede0b503