gitea

package
v0.0.4-alpha.20 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: EUPL-1.2 Imports: 5 Imported by: 0

Documentation

Overview

Package gitea provides a thin wrapper around the Gitea Go SDK for managing repositories, issues, and pull requests on a Gitea instance.

Authentication is resolved from config file, environment variables, or flag overrides:

  1. ~/.core/config.yaml keys: gitea.token, gitea.url
  2. GITEA_TOKEN + GITEA_URL environment variables (override config file)
  3. Flag overrides via core gitea config --url/--token (highest priority)

Index

Constants

View Source
const (
	// ConfigKeyURL is the config key for the Gitea instance URL.
	ConfigKeyURL = "gitea.url"
	// ConfigKeyToken is the config key for the Gitea API token.
	ConfigKeyToken = "gitea.token"

	// DefaultURL is the default Gitea instance URL.
	DefaultURL = "https://gitea.snider.dev"
)

Variables

This section is empty.

Functions

func ResolveConfig

func ResolveConfig(flagURL, flagToken string) (url, token string, err error)

ResolveConfig resolves the Gitea URL and token from all config sources. Flag values take highest priority, then env vars, then config file.

func SaveConfig

func SaveConfig(url, token string) error

SaveConfig persists the Gitea URL and/or token to the config file.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps the Gitea SDK client with config-based auth.

func New

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

New creates a new Gitea API client for the given URL and token.

func NewFromConfig

func NewFromConfig(flagURL, flagToken string) (*Client, error)

NewFromConfig creates a Gitea client using the standard config resolution:

  1. ~/.core/config.yaml keys: gitea.token, gitea.url
  2. GITEA_TOKEN + GITEA_URL environment variables (override config file)
  3. Provided flag overrides (highest priority; pass empty to skip)

func (*Client) API

func (c *Client) API() *gitea.Client

API exposes the underlying SDK client for direct access.

func (*Client) CreateIssue

func (c *Client) CreateIssue(owner, repo string, opts gitea.CreateIssueOption) (*gitea.Issue, error)

CreateIssue creates a new issue in the given repository.

func (*Client) CreateMirror

func (c *Client) CreateMirror(owner, name, cloneURL, authToken string) (*gitea.Repository, error)

CreateMirror creates a mirror repository on Gitea from a GitHub clone URL. This uses the Gitea migration API to set up a pull mirror. If authToken is provided, it is used to authenticate against the source (e.g. for private GitHub repos).

func (*Client) CreateOrgRepo

func (c *Client) CreateOrgRepo(org string, opts gitea.CreateRepoOption) (*gitea.Repository, error)

CreateOrgRepo creates a new empty repository under an organisation.

func (*Client) DeleteRepo

func (c *Client) DeleteRepo(owner, name string) error

DeleteRepo deletes a repository from Gitea.

func (*Client) GetCommentBodies

func (c *Client) GetCommentBodies(owner, repo string, pr int64) ([]Comment, error)

GetCommentBodies returns all comment bodies for a pull request. This reads full content, which is safe on the home lab Gitea instance.

func (*Client) GetIssue

func (c *Client) GetIssue(owner, repo string, number int64) (*gitea.Issue, error)

GetIssue returns a single issue by number.

func (*Client) GetIssueBody

func (c *Client) GetIssueBody(owner, repo string, issue int64) (string, error)

GetIssueBody returns the body text of an issue. This reads full content, which is safe on the home lab Gitea instance.

func (*Client) GetPRMeta

func (c *Client) GetPRMeta(owner, repo string, pr int64) (*PRMeta, error)

GetPRMeta returns structural signals for a pull request. This is the Gitea side of the dual MetaReader described in the pipeline design.

func (*Client) GetPullRequest

func (c *Client) GetPullRequest(owner, repo string, number int64) (*gitea.PullRequest, error)

GetPullRequest returns a single pull request by number.

func (*Client) GetRepo

func (c *Client) GetRepo(owner, name string) (*gitea.Repository, error)

GetRepo returns a single repository by owner and name.

func (*Client) ListIssues

func (c *Client) ListIssues(owner, repo string, opts ListIssuesOpts) ([]*gitea.Issue, error)

ListIssues returns issues for the given repository.

func (*Client) ListOrgRepos

func (c *Client) ListOrgRepos(org string) ([]*gitea.Repository, error)

ListOrgRepos returns all repositories for the given organisation.

func (*Client) ListPullRequests

func (c *Client) ListPullRequests(owner, repo string, state string) ([]*gitea.PullRequest, error)

ListPullRequests returns pull requests for the given repository.

func (*Client) ListUserRepos

func (c *Client) ListUserRepos() ([]*gitea.Repository, error)

ListUserRepos returns all repositories for the authenticated user.

func (*Client) URL

func (c *Client) URL() string

URL returns the Gitea instance URL.

type Comment

type Comment struct {
	ID        int64
	Author    string
	Body      string
	CreatedAt time.Time
	UpdatedAt time.Time
}

Comment represents a comment with metadata.

type ListIssuesOpts

type ListIssuesOpts struct {
	State string // "open", "closed", "all"
	Page  int
	Limit int
}

ListIssuesOpts configures issue listing.

type PRMeta

type PRMeta struct {
	Number       int64
	Title        string
	State        string
	Author       string
	Branch       string
	BaseBranch   string
	Labels       []string
	Assignees    []string
	IsMerged     bool
	CreatedAt    time.Time
	UpdatedAt    time.Time
	CommentCount int
}

PRMeta holds structural signals from a pull request, used by the pipeline MetaReader for AI-driven workflows.

Jump to

Keyboard shortcuts

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