mirror of
https://gitea.com/gitea/tea.git
synced 2026-09-12 00:16:36 -04:00
`tea pr merge <index>` reported 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 the wrong way.
Gitea answers an unmergeable PR with a 405 and a body naming the cause, but the
SDK's MergePullRequest is built on getStatusCode, which returns only the status
code and never calls statusCodeToErr. tea receives success=false, err=nil with no
server explanation to pass on, so it guessed.
Changes:
- Derive the reason from the PR 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).
- Include the PR index in the error.
- Add table-driven tests for every reason, plus a failed follow-up lookup.
The extra API call happens only on the failure path.
Fixes #1022
Signed-off-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 | ||