gitea.tea/modules/print
Tyler 23a3967e15 fix(print): distinguish draft PRs from conflicting PRs (#1012)
## 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 <xiaolunwen@gmail.com>
Co-authored-by: Tyler <tyler@dinsmoor.us>
Co-committed-by: Tyler <tyler@dinsmoor.us>
2026-05-28 17:29:00 +00:00
..
actions.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
actions_runs.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
actions_runs_test.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
actions_test.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
attachment.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
branch.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
branch_test.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
comment.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
formatters.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
issue.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
label.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
login.go update import path to use gitea.dev (#1003) 2026-05-23 17:26:43 +00:00
markdown.go Update to charm libraries v2 (#923) 2026-03-09 16:36:00 +00:00
milestone.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
notification.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
organization.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
pull.go fix(print): distinguish draft PRs from conflicting PRs (#1012) 2026-05-28 17:29:00 +00:00
pull_review_comment.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
pull_test.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
release.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
repo.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
repo_test.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
sshkey.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
table.go refactor: code cleanup across codebase (#947) 2026-04-08 03:38:49 +00:00
table_test.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
times.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
user.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
webhook.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
webhook_test.go Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006) 2026-05-26 04:51:09 +00:00
wiki.go feat: add wiki CLI commands (#998) 2026-05-26 21:14:47 +00:00
wiki_test.go feat: add wiki CLI commands (#998) 2026-05-26 21:14:47 +00:00