mirror of
https://gitea.com/gitea/tea.git
synced 2026-09-10 07:26:33 -04:00
## Problem
Tea commands fail when run from git worktrees with the error:
Remote repository required: Specify ID via --repo or execute from a
local git repo.
Even though the worktree is in a valid git repository with remotes
configured.
Additionally, `tea pr create` was missing context validation, showing
cryptic errors like `"path segment [0]
is empty"` instead of helpful messages.
## Root Cause
1. **Worktree issue**: go-git's `PlainOpenWithOptions` was not
configured to read the `commondir` file that
git worktrees use. This file points to the main repository's `.git`
directory where remotes are actually
stored (worktrees don't have their own remotes).
2. **PR create issue**: Missing `ctx.Ensure()` validation meant errors
weren't caught early with clear
messages.
## Solution
### 1. Enable worktree support (`modules/git/repo.go`)
```go
EnableDotGitCommonDir: true, // Enable commondir support for worktrees
This tells go-git to:
- Read the commondir file in .git/worktrees/<name>/commondir
- Follow the reference (typically ../..) to the main repository
- Load remotes from the main repo's config
2. Add context validation (cmd/pulls/create.go)
ctx.Ensure(context.CtxRequirement{
LocalRepo: true,
RemoteRepo: true,
})
Provides clear error messages and matches the pattern used in pr
checkout (fixed in commit
|
||
|---|---|---|
| .. | ||
| actions | ||
| admin/users | ||
| attachments | ||
| branches | ||
| flags | ||
| issues | ||
| labels | ||
| login | ||
| milestones | ||
| notifications | ||
| organizations | ||
| pulls | ||
| releases | ||
| repos | ||
| times | ||
| webhooks | ||
| actions.go | ||
| admin.go | ||
| attachments.go | ||
| branches.go | ||
| categories.go | ||
| clone.go | ||
| cmd.go | ||
| comment.go | ||
| issues.go | ||
| labels.go | ||
| login.go | ||
| logout.go | ||
| man.go | ||
| milestones.go | ||
| notifications.go | ||
| open.go | ||
| organizations.go | ||
| pulls.go | ||
| releases.go | ||
| repos.go | ||
| times.go | ||
| webhooks.go | ||
| whoami.go | ||