From 23a3967e15c2b7365f165ae8f94ea6dc8cd8f061 Mon Sep 17 00:00:00 2001 From: Tyler Date: Thu, 28 May 2026 17:29:00 +0000 Subject: [PATCH] fix(print): distinguish draft PRs from conflicting PRs (#1012) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## The bug `tea pulls create` and `tea pulls edit` print `• **Conflicting files**` for any open PR that the server reports as `mergeable: false`. But Gitea's API returns `mergeable: false` for **draft PRs by design** — drafts cannot be merged regardless of conflict state. The current code conflates "not mergeable for any reason" with "has file conflicts." ### Reproduction (gitea.com 1.26.0+dev) ``` $ tea pulls create --base main --head my-branch --title "WIP: clean diff" --description "..." # #N WIP: clean diff (open) ... • **Conflicting files** ← misleading • Maintainers are allowed to edit ``` The PR has no actual conflicts. The web UI shows it as draft + cleanly diffable. `tea pulls edit --title "WIP: ..."` shows the same misleading line. API confirms the root signal: ``` $ curl /api/v1/repos/owner/repo/pulls/N { "draft": true, "mergeable": false, ... } ``` Strip the WIP prefix, and `mergeable` flips back to `true`. So `mergeable=false` here means "blocked because draft," not "conflicts." ## Fix Distinguish the two reasons in `modules/print/pull.go`: ```go switch { case pr.Mergeable: out += "- No Conflicts\n" case pr.Draft: out += "- Draft (not mergeable until marked ready)\n" default: out += "- **Conflicting files**\n" } ``` Real conflicts still fall through to the existing "Conflicting files" message. ## Behavior matrix | PR state | API `mergeable` | Before | After | |---|---|---|---| | Open, clean, ready | true | No Conflicts | No Conflicts | | Open, draft, clean | false | **Conflicting files** (wrong) | **Draft (not mergeable until marked ready)** | | Open, conflicting | false | Conflicting files | Conflicting files | | Closed/merged | — | (no line shown) | (no line shown) | ## Verification Against `dinsmoor/tea-testing` PR #6 on gitea.com: - Set title to `WIP: ...` → API `mergeable=false`, `draft=true` → tea prints `Draft (not mergeable until marked ready)` ✓ - Strip WIP → API `mergeable=true`, `draft=false` → tea prints `No Conflicts` ✓ --- This patch was authored interactively with an AI assistant, driven and reviewed by a human (Tyler / @dinsmoor) every step. *pull request created by Tyler's lovingly wrangled demon machine <3* Reviewed-on: https://gitea.com/gitea/tea/pulls/1012 Reviewed-by: Lunny Xiao Co-authored-by: Tyler Co-committed-by: Tyler --- modules/print/pull.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/print/pull.go b/modules/print/pull.go index 5e415836..1be458f3 100644 --- a/modules/print/pull.go +++ b/modules/print/pull.go @@ -59,9 +59,12 @@ func PullDetails(pr *gitea.PullRequest, reviews []*gitea.PullReview, ciStatus *g } if pr.State == gitea.StateOpen { - if pr.Mergeable { + switch { + case pr.Mergeable: out += "- No Conflicts\n" - } else { + case pr.Draft: + out += "- Draft (not mergeable until marked ready)\n" + default: out += "- **Conflicting files**\n" } }