Closes#1009.
## The standard fork-flow
The textbook workflow for opening a PR with any git CLI (gh, glab, hub, tea, etc.) is:
1. Fork `upstream/repo` on the server.
2. Clone the fork locally; add `upstream` as a second remote.
3. Branch off, commit, push the branch to your fork.
4. Tell the tool: "open a PR on `upstream/repo`, source is `fork:branch`".
In tea that's:
```
tea pulls create --repo upstream/repo --head fork:branch --base main
```
This is the flow tea supported before #850 and the flow this repo's own contribution model assumes.
## What broke
#850 ("Enable git worktree support and improve pr create error handling", Nov 2025) correctly addressed worktree detection by adding `LocalRepo: true` to `runPullsCreate`'s `CtxRequirement`. But that requirement is checked before `--repo` is interpreted, and a slug-style `--repo gitea/tea` doesn't satisfy `LocalRepo` — only a path does.
Result: the standard fork-flow invocation above started failing with:
```
Error: local repository required: execute from a repo dir, or specify a path with --repo
```
— which is misleading, because the user IS in a repo dir and `--repo` IS set.
## The fix
Only require `LocalRepo` when the command genuinely needs the working tree:
- **Interactive mode** (no flags) — uses tree info for prompts.
- **`--head` omitted** — defaults head from the current branch.
Otherwise the command runs with just `RemoteRepo`, and `task.CreatePull` takes the explicit `--repo` and `--head` as given. The #850 worktree fix is preserved for the in-tree path.
## Behavior table
| Invocation | Before | After |
|---|---|---|
| `tea pulls create` (interactive) | works | works (unchanged) |
| `tea pulls create --head my-branch --base main` (in-tree, same repo) | works | works (unchanged) |
| `tea pulls create --repo upstream/repo --head fork:branch --base main` (fork-flow) | **fails with misleading error** | **works** |
| `tea pulls create --repo upstream/repo --base main` (no `--head`, no working tree) | fails | still fails with the same error (correctly — head can't be defaulted without a working tree or explicit flag) |
## Verification
Smoke-tested by opening a PR from `/tmp` (deliberately not a git repo):
```
cd /tmp
tea-dev pulls create --login gitea.com --repo dinsmoor/tea-testing \
--head dinsmoor:xfork-smoke --base main \
--title "xfork smoke test" --description "..."
→ https://gitea.com/dinsmoor/tea-testing/pulls/4
```
And in fact, **this very PR was opened using the patched binary** invoked from `/tmp`, since the released `tea` still has the bug.
---
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*
---------
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/1010
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Tyler <tyler@dinsmoor.us>
Co-committed-by: Tyler <tyler@dinsmoor.us>