* feat(gitea): add Gitea Go SDK integration and CLI commands Add `code.gitea.io/sdk/gitea` and create `pkg/gitea/` package for connecting to self-hosted Gitea instances. Wire into CLI as `core gitea` command group with repo, issue, PR, mirror, and sync subcommands. pkg/gitea/: - client.go: thin wrapper around SDK with config-based auth - config.go: env → config file → flags resolution - repos.go: list/get/create/delete repos, create mirrors - issues.go: list/get/create issues and pull requests - meta.go: pipeline MetaReader for structural + content signals internal/cmd/gitea/: - config: set URL/token, test connection - repos: list repos with table output - issues: list/create issues - prs: list pull requests - mirror: create GitHub→Gitea mirrors with auth - sync: upstream/main branch strategy (--setup + ongoing sync) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * style(gitea): fix gofmt formatting Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(gitea): address Copilot review feedback - Use os.UserHomeDir() instead of sh -c "echo $HOME" for home dir expansion - Distinguish "already exists" from real errors in createMainFromUpstream - Fix package docs to match actual config resolution order - Guard token masking against short tokens (< 8 chars) - Paginate ListIssueComments in GetPRMeta and GetCommentBodies - Rename loop variable to avoid shadowing receiver in GetCommentBodies - Move gitea SDK to direct require block in go.mod Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
// Package gitea provides a thin wrapper around the Gitea Go SDK
|
|
// for managing repositories, issues, and pull requests on a Gitea instance.
|
|
//
|
|
// Authentication is resolved from config file, environment variables, or flag overrides:
|
|
//
|
|
// 1. ~/.core/config.yaml keys: gitea.token, gitea.url
|
|
// 2. GITEA_TOKEN + GITEA_URL environment variables (override config file)
|
|
// 3. Flag overrides via core gitea config --url/--token (highest priority)
|
|
package gitea
|
|
|
|
import (
|
|
"code.gitea.io/sdk/gitea"
|
|
|
|
"github.com/host-uk/core/pkg/log"
|
|
)
|
|
|
|
// Client wraps the Gitea SDK client with config-based auth.
|
|
type Client struct {
|
|
api *gitea.Client
|
|
url string
|
|
}
|
|
|
|
// New creates a new Gitea API client for the given URL and token.
|
|
func New(url, token string) (*Client, error) {
|
|
api, err := gitea.NewClient(url, gitea.SetToken(token))
|
|
if err != nil {
|
|
return nil, log.E("gitea.New", "failed to create client", err)
|
|
}
|
|
|
|
return &Client{api: api, url: url}, nil
|
|
}
|
|
|
|
// API exposes the underlying SDK client for direct access.
|
|
func (c *Client) API() *gitea.Client { return c.api }
|
|
|
|
// URL returns the Gitea instance URL.
|
|
func (c *Client) URL() string { return c.url }
|