forgejo

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package forgejo provides access to Forgejo via the forgejo-sdk.

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
}

func New

func New(cfg operations.ForgejoConfig) (*Client, error)

New builds a Forgejo client from the given credentials.

func (*Client) CloseIssue

func (c *Client) CloseIssue(ctx context.Context, repo string, number int) error

CloseIssue closes an issue.

func (*Client) ClosePR

func (c *Client) ClosePR(ctx context.Context, repo string, number int) error

ClosePR closes a pull request without merging it.

func (*Client) CommentIssue

func (c *Client) CommentIssue(ctx context.Context, repo string, number int, body string) error

CommentIssue adds a comment to an issue.

func (*Client) CommentPR

func (c *Client) CommentPR(ctx context.Context, repo string, number int, body string) error

CommentPR adds a comment to a pull request.

func (*Client) CreateIssue

CreateIssue opens a new issue.

func (*Client) CreatePR

func (c *Client) CreatePR(ctx context.Context, in operations.PRInput) (operations.PRDetail, error)

CreatePR opens a pull request.

func (*Client) CreateRepo

func (c *Client) CreateRepo(ctx context.Context, in operations.RepoInput) (operations.Repo, error)

CreateRepo creates a repository in the authenticated user's namespace, or in an organization when in.Owner is set.

func (*Client) DeleteRepo

func (c *Client) DeleteRepo(ctx context.Context, fullName string) error

DeleteRepo deletes a repository. fullName is owner/name.

func (*Client) FetchSpec

func (c *Client) FetchSpec(ctx context.Context, repo string, number int) (operations.FetchSpec, error)

FetchSpec returns how to fetch a pull request head locally.

Forgejo mirrors GitHub's refs/pull/N/head namespace, so the head commit is fetchable even for pull requests opened from a fork.

func (*Client) GetIssue

func (c *Client) GetIssue(ctx context.Context, repo string, number int) (operations.IssueDetail, error)

GetIssue returns a single issue in full.

func (*Client) GetPR

func (c *Client) GetPR(ctx context.Context, repo string, number int) (operations.PRDetail, error)

GetPR returns a single pull request in full.

func (*Client) ListIssues

func (c *Client) ListIssues(ctx context.Context) ([]operations.Issue, error)

ListIssues returns open issues assigned to the authenticated user.

The /repos/issues/search endpoint returns pull requests too unless type=issues is set (the SDK sends type= only when IssueType is non-empty), and it does not restrict results to the current user. Resolve the authenticated user and keep only issues assigned to them, mirroring the GitHub (filter=assigned) and GitLab (scope=assigned_to_me) semantics.

func (*Client) ListPRs

func (c *Client) ListPRs(ctx context.Context) ([]operations.PR, error)

ListPRs returns open pull requests across the user's repositories.

func (*Client) ListProjects

func (c *Client) ListProjects(ctx context.Context) ([]operations.Project, error)

ListProjects returns ErrNotSupported: Forgejo has no projects/boards API. The web UI has no project boards either, so there is nothing to enumerate; issues and pull requests remain available.

func (*Client) ListRepos

func (c *Client) ListRepos(ctx context.Context) ([]operations.Repo, error)

ListRepos returns the repositories the authenticated user has access to.

func (*Client) ListRuns

func (c *Client) ListRuns(ctx context.Context, fullName string) ([]operations.Run, error)

ListRuns lists Actions task runs for a repository. fullName is owner/name.

The SDK does not wrap the Actions API, so /repos/{owner}/{repo}/actions/tasks is called directly. Tasks carry the workflow name, branch and run number, which map onto the unified Run shape.

func (*Client) ListWorkflows

func (c *Client) ListWorkflows(ctx context.Context, fullName string) ([]operations.Workflow, error)

ListWorkflows lists Actions workflow definitions for a repository. fullName is owner/name.

Forgejo has no endpoint that enumerates workflows (unlike GitHub's /actions/workflows), so the workflow directories are listed from the default branch instead. Forgejo reads .forgejo/workflows first and falls back to .github/workflows; both are reported here, deduplicated by file name.

func (*Client) MergePR

func (c *Client) MergePR(ctx context.Context, repo string, number int, opts operations.MergeOptions) error

MergePR merges a pull request.

func (*Client) Name

func (c *Client) Name() string

Name returns the instance name.

func (*Client) PRDiff

func (c *Client) PRDiff(ctx context.Context, repo string, number int) (string, error)

PRDiff returns the unified diff of a pull request.

func (*Client) RenameRepo

func (c *Client) RenameRepo(ctx context.Context, fullName, newName string) (operations.Repo, error)

RenameRepo renames a repository. fullName is owner/name.

func (*Client) SetForgeLabel

func (c *Client) SetForgeLabel(label string)

SetForgeLabel overrides the forge label the client stamps on returned resources. Used to give user-named aliases (e.g. "gitea") the right identity in listings while the Forgejo client does the API work.

func (*Client) SetInstance

func (c *Client) SetInstance(name string)

SetInstance names this client's instance (default: the forge type).

func (*Client) SetVisibility

func (c *Client) SetVisibility(ctx context.Context, fullName string, private bool) (operations.Repo, error)

SetVisibility changes whether a repository is private. fullName is owner/name.

Jump to

Keyboard shortcuts

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