forgejo

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package forgejo lists and mirrors repositories from a self-hosted Forgejo (or Gitea) instance over its REST API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL *url.URL
	Token   string
	HTTP    *http.Client

	// SkipMirrors excludes repositories Forgejo reports as mirrors of an
	// external upstream from ListRepos. Off by default -- the zero value
	// backs up exactly what earlier versions of this client did.
	SkipMirrors bool
}

Client lists and mirrors repositories from a self-hosted Forgejo instance.

func New

func New(base, token string) (*Client, error)

New builds a Client against the given base URL.

func (*Client) ListRepos

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

ListRepos implements backup.Lister by paging through /api/v1/repos/search. The archived parameter on that endpoint is tri-state -- true, false, or omitted for all -- so StateAll is a single pass rather than two.

func (*Client) Remote

func (c *Client) Remote(r backup.Repo) backup.Remote

Remote implements backup.Remoter by deriving the clone URL from the configured base URL rather than the API's own clone_url, which can report a host or port the caller can't actually reach -- inside a container it's the container's internal port, and behind a reverse proxy it can be wrong entirely. Forgejo's git-http-backend accepts the same "token <t>" Authorization header as its REST API, so no username is needed.

Jump to

Keyboard shortcuts

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