forgejo

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package forgejo implements backend.Backend against the Forgejo REST API (api/v1). Forgejo is Gitea-derived, but its API was verified directly against a live Forgejo instance (codeberg.org) rather than assumed identical: same base path, same release field names (tag_name/name/body/draft), same "Authorization: token <t>" auth scheme, same page/limit list pagination — so the adapter logic mirrors internal/backend/gitea.

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 implements backend.Backend against a Forgejo instance's REST API.

func New

func New(baseURL, owner, repo, token string) *Client

New returns a Client for owner/repo against the Forgejo instance at baseURL (e.g. "https://codeberg.org" — no trailing slash or "/api/v1" suffix needed, New adds it). Forgejo is self-hosted, so baseURL is always required.

func (*Client) CommitURL

func (c *Client) CommitURL(sha string) string

CommitURL implements backend.Backend, using baseURL as the instance's web root (same host as the API, just without the "/api/v1" prefix).

func (*Client) CompareURL added in v0.2.0

func (c *Client) CompareURL(from, to string) string

CompareURL implements backend.Backend.

func (*Client) Publish

func (c *Client) Publish(ctx context.Context, tag string) error

Publish implements backend.Backend: flips the draft release matching tag to published. As with GitHub/Gitea, the underlying git tag doesn't exist until this point; leaving target_commitish unset in the PATCH means Forgejo keeps whatever was set at draft-creation time (also left unset, which resolves to the default branch), so publish always tags the default branch's current state rather than a stale commitish.

func (*Client) ResolveAuthor

func (c *Client) ResolveAuthor(_ context.Context, _ string) (backend.AuthorReference, bool, error)

ResolveAuthor implements backend.Backend. Unlike GitHub's "get a commit" endpoint, no Forgejo endpoint returning a commit's linked account has been verified against a live instance — per ADR-0001, this always reports "not supported" rather than attempting an unverified lookup.

func (*Client) ResolvePR

func (c *Client) ResolvePR(_ context.Context, _ string) (commit.PRReference, bool, error)

ResolvePR implements backend.Backend. Forgejo does expose a commits/{sha}/pull lookup, but per ADR-0001 it's confirmed to return the wrong PR in some cases — attaching an incorrect link is worse than attaching none, so this deliberately never calls it and always reports "not supported". Only ticket 05's text extraction (the "Reviewed-on:" trailer) applies for Forgejo.

func (*Client) UpsertDraft

func (c *Client) UpsertDraft(ctx context.Context, req backend.UpsertDraftRequest) error

UpsertDraft implements backend.Backend.

Jump to

Keyboard shortcuts

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