forgejo

package
v0.78.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

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

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

func NewClient(instanceURL, token, username string) *Client

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) AddLabel added in v0.69.0

func (c *Client) AddLabel(ctx context.Context, owner, name string, number int, label string) error

AddLabel implements dashboard.PullRequestLabeler: adds label to owner/name#number — Renovate's own rebase/retry trigger on this forge. Forgejo's AddIssueLabels takes label IDs, not names (unlike GitHub's equivalent), so this looks the repo's own labels up first to resolve label to its ID. A repo with no label by that name fails informatively rather than silently doing nothing — Renovate doesn't create the label itself, the repo owner (or Renovate's own onboarding) does.

func (*Client) EnsureWebhook added in v0.56.0

func (c *Client) EnsureWebhook(ctx context.Context, owner, name, targetURL, secret string) error

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

func (c *Client) HasWebhook(ctx context.Context, owner, name string) (bool, error)

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

func (c *Client) ListRepos(ctx context.Context) ([]dashboard.RepoRef, error)

ListRepos returns the repositories this Client is configured to track — see NewClient for the two modes.

func (*Client) MergePullRequest added in v0.62.0

func (c *Client) MergePullRequest(ctx context.Context, owner, name string, number int) error

MergePullRequest implements dashboard.PullRequestMerger: merges owner/name#number using the repo's own configured default merge style. Unlike GitHub, Forgejo's merge API has no "use the repo default" sentinel — MergePullRequestOption.Style is a required field on the wire — so this looks the repo's DefaultMergeStyle up first rather than hardcoding one style for every repo regardless of its own settings.

func (*Client) SetWebhookPath added in v0.54.0

func (c *Client) SetWebhookPath(path string)

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.

func (*Client) UpdateBranch added in v0.63.0

func (c *Client) UpdateBranch(ctx context.Context, owner, name string, number int) (bool, error)

UpdateBranch implements dashboard.BranchUpdater: merges owner/name#number's base branch into its head branch, bringing it up to date. Forgejo's SDK call is synchronous — accepted is always false here — unlike GitHub's async equivalent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL