Replace all GitHub API and gh CLI dependencies with Forgejo SDK via pkg/forge. The bash dispatcher burned a week of credit in a day due to bugs — the jobrunner now talks directly to Forgejo. - Add forge client methods: CreateIssueComment, CloseIssue, MergePullRequest, SetPRDraft, ListPRReviews, GetCombinedStatus, DismissReview - Create ForgejoSource implementing JobSource (epic polling, checklist parsing, commit status via combined status API) - Rewrite all 5 handlers to accept *forge.Client instead of shelling out - Replace ResolveThreadsHandler with DismissReviewsHandler (Forgejo has no thread resolution API — dismiss stale REQUEST_CHANGES reviews instead) - Delete pkg/jobrunner/github/ and handlers/exec.go entirely - Update internal/core-ide/headless.go to wire Forgejo source and handlers - All 33 tests pass with mock Forgejo HTTP servers Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
// Package forge provides a thin wrapper around the Forgejo Go SDK
|
|
// for managing repositories, issues, and pull requests on a Forgejo instance.
|
|
//
|
|
// Authentication is resolved from config file, environment variables, or flag overrides:
|
|
//
|
|
// 1. ~/.core/config.yaml keys: forge.token, forge.url
|
|
// 2. FORGE_TOKEN + FORGE_URL environment variables (override config file)
|
|
// 3. Flag overrides via core forge config --url/--token (highest priority)
|
|
package forge
|
|
|
|
import (
|
|
forgejo "codeberg.org/mvdkleijn/forgejo-sdk/forgejo/v2"
|
|
|
|
"github.com/host-uk/core/pkg/log"
|
|
)
|
|
|
|
// Client wraps the Forgejo SDK client with config-based auth.
|
|
type Client struct {
|
|
api *forgejo.Client
|
|
url string
|
|
token string
|
|
}
|
|
|
|
// New creates a new Forgejo API client for the given URL and token.
|
|
func New(url, token string) (*Client, error) {
|
|
api, err := forgejo.NewClient(url, forgejo.SetToken(token))
|
|
if err != nil {
|
|
return nil, log.E("forge.New", "failed to create client", err)
|
|
}
|
|
|
|
return &Client{api: api, url: url, token: token}, nil
|
|
}
|
|
|
|
// API exposes the underlying SDK client for direct access.
|
|
func (c *Client) API() *forgejo.Client { return c.api }
|
|
|
|
// URL returns the Forgejo instance URL.
|
|
func (c *Client) URL() string { return c.url }
|