Documentation
¶
Overview ¶
Package forgejo is a client for the pieces of the Forgejo API (Gitea-compatible) forge-dashboard needs — the same shape as internal/github, against a different API under a self-hosted host. Driven by code.gitea.io/sdk/gitea, the official Gitea Go client and the one Forgejo's own API compatibility targets, rather than hand-rolled requests.
Index ¶
- type Client
- func (c *Client) EnsureWebhook(ctx context.Context, owner, name, targetURL, secret string) error
- func (c *Client) HasWebhook(ctx context.Context, owner, name string) (bool, error)
- func (c *Client) ListOpenIssues(ctx context.Context, owner, name, repo string) ([]dashboard.Issue, error)
- func (c *Client) ListOpenPullRequests(ctx context.Context, owner, name, repo string) ([]dashboard.PullRequest, error)
- func (c *Client) ListRepos(ctx context.Context) ([]dashboard.RepoRef, error)
- func (c *Client) SetWebhookPath(path string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to a Forgejo instance's API, either as an authenticated user (a token) or anonymously against one user's public repositories on that instance (a username, no token at all).
func NewClient ¶
NewClient returns a Client against instanceURL (e.g. "https://git.higherlearning.eu"). With token set, it authenticates as that user and ListRepos returns every repo the token can push to, private included. With token empty and username set, every request goes out unauthenticated and ListRepos returns only username's public repos on that instance.
func (*Client) EnsureWebhook ¶ added in v0.56.0
EnsureWebhook implements dashboard.WebhookManager: create a webhook targeting targetURL if owner/name has none yet, or bring an existing one (found by matching targetURL's own path, not c.webhookPath — this method is self-contained even if SetWebhookPath was never called) back to active with the right config rather than creating a second, duplicate hook.
func (*Client) HasWebhook ¶ added in v0.54.0
HasWebhook implements dashboard.WebhookChecker: does repo owner/name already have a webhook whose target URL is this account's own webhook endpoint. Forgejo's hooks API has no separate read-only scope — listing needs the same write:repository scope creating one does (see #234's research, cited on settings.html's token instructions).
func (*Client) ListOpenIssues ¶
func (c *Client) ListOpenIssues(ctx context.Context, owner, name, repo string) ([]dashboard.Issue, error)
ListOpenIssues returns every open issue against repo. Forgejo's issues endpoint takes type=issues to exclude pull requests server-side, unlike GitHub's equivalent — no client-side filtering needed here.
func (*Client) ListOpenPullRequests ¶
func (c *Client) ListOpenPullRequests(ctx context.Context, owner, name, repo string) ([]dashboard.PullRequest, error)
ListOpenPullRequests returns every open pull request against repo, with CI already resolved. repo is owner-qualified ("alrayyes/tempus-fugit").
func (*Client) ListRepos ¶
ListRepos returns the repositories this Client is configured to track — see NewClient for the two modes.
func (*Client) SetWebhookPath ¶ added in v0.54.0
SetWebhookPath tells Client the path (not the full URL — see dashboard.WebhookTargetsPath) this account's own Forgejo webhook endpoint lives at, e.g. "/api/webhooks/forgejo/<token>". Left unset, HasWebhook always reports false without calling the forge at all — the same "optional, degrades quietly" shape RateLimit's nil pointer already uses elsewhere in this codebase.