mirror of
https://gitea.com/gitea/tea.git
synced 2026-09-10 07:26:33 -04:00
## Problem `tea pr merge <index>` reports the same misleading error for every refusal: ``` failed to merge PR, is it still open? ``` The PR usually *is* still open — `tea pr <index>` shows it as open and lists `Conflicting files` — so the message sends users looking in the wrong direction. ## Root cause Gitea answers an unmergeable PR with a 405 and a body naming the actual cause. The SDK's `MergePullRequest` is built on `getStatusCode`, which returns only the status code and never calls `statusCodeToErr`, so the body is discarded. tea receives `success=false, err=nil` with no server explanation to pass on, and fell back to guessing that the PR might be closed. ## Changes - Derive the refusal reason from the pull request when a merge fails: already merged, closed, draft, or not mergeable. - When the PR looks mergeable but was refused anyway, name the conditions tea cannot observe (required status checks, requested reviews, branch protection) instead of guessing. - Include the PR index in the error. - Add table-driven tests for every reason, plus the case where the follow-up PR lookup fails. The extra API call happens only on the failure path. Fixes #1022 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-on: https://gitea.com/gitea/tea/pulls/1107 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Jan Baer <jan.s.baer@googlemail.com> |
||
|---|---|---|
| .. | ||
| assignees.go | ||
| issue_create.go | ||
| issue_edit.go | ||
| labels.go | ||
| labels_export.go | ||
| login_create.go | ||
| login_create_test.go | ||
| login_httpsign.go | ||
| login_ssh.go | ||
| login_status.go | ||
| login_status_test.go | ||
| milestone_create.go | ||
| pull_checkout.go | ||
| pull_clean.go | ||
| pull_create.go | ||
| pull_create_test.go | ||
| pull_edit.go | ||
| pull_merge.go | ||
| pull_merge_test.go | ||
| pull_review.go | ||
| pull_review_comment.go | ||
| repo_clone.go | ||
| wiki.go | ||
| wiki_test.go | ||