gitea

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package gitea implements the forge.IssueTracker interface for Gitea using the official Gitea Go 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
}

Client implements forge.IssueTracker for Gitea repositories.

func New

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

New creates a Gitea IssueTracker client for the given owner/repo. The url should be the Gitea instance base URL (e.g., "http://localhost:3000"). Token authenticates via Gitea's "token <token>" header format.

func (*Client) AddComment

func (c *Client) AddComment(ctx context.Context, number int, body string) (comment *forge.Comment, err error)

AddComment posts a new comment on the given issue.

func (*Client) AddLabel

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

AddLabel adds a single label to the given issue.

func (*Client) Assign

func (c *Client) Assign(ctx context.Context, number int, assignee string) error

Assign adds an assignee to the given issue via read-modify-write. Gitea has no dedicated assign endpoint; we read the current assignees, append the new one, and write back via EditIssue.

func (*Client) CreateBranch added in v0.1.5

func (c *Client) CreateBranch(_ context.Context, name string) error

CreateBranch creates a new branch from "main" HEAD.

func (*Client) CreateIssue

func (c *Client) CreateIssue(ctx context.Context, req *forge.CreateIssueRequest) (issue *forge.Issue, err error)

CreateIssue creates a new issue on the repository.

func (*Client) CreateOrUpdateFile added in v0.1.5

func (c *Client) CreateOrUpdateFile(_ context.Context, branch, path, content, message string) error

CreateOrUpdateFile creates or updates a file on the given branch. If the file already exists its SHA is fetched first so that the update succeeds.

func (*Client) CreatePullRequest added in v0.1.6

func (c *Client) CreatePullRequest(ctx context.Context, req *forge.CreatePRRequest) (*forge.PullRequest, error)

CreatePullRequest creates a new pull request on the repository.

func (*Client) DeleteTestBranch added in v0.1.11

func (c *Client) DeleteTestBranch(_ context.Context, name string) error

DeleteTestBranch deletes a branch by name. It is NOT part of the forge interface and exists solely to support integration test cleanup.

func (*Client) GetCommitLog added in v0.1.10

func (c *Client) GetCommitLog(_ context.Context, branch string, limit int) ([]forge.Commit, error)

GetCommitLog returns the most recent commits on a branch. If branch is empty, "main" is used. Limit defaults to 20 if <= 0.

func (*Client) GetDiff added in v0.1.10

func (c *Client) GetDiff(ctx context.Context, base, head string) (string, error)

GetDiff returns the unified diff comparing base and head refs. It calls the Gitea compare API with the .diff suffix to retrieve actual diff content (hunks, file stats). Falls back to a summary if the raw diff endpoint is unavailable.

func (*Client) GetIssue

func (c *Client) GetIssue(ctx context.Context, number int) (issue *forge.Issue, err error)

GetIssue retrieves a single issue by number.

func (*Client) GetPRChecks added in v0.1.6

func (c *Client) GetPRChecks(ctx context.Context, number int) ([]forge.Check, error)

GetPRChecks returns the CI status checks for a pull request's head commit.

func (*Client) GetPullRequest added in v0.1.6

func (c *Client) GetPullRequest(ctx context.Context, number int) (*forge.PullRequest, error)

GetPullRequest retrieves a single pull request by number.

func (*Client) ListBranches added in v0.1.10

func (c *Client) ListBranches(_ context.Context) ([]forge.Branch, error)

ListBranches returns all branches in the repository.

func (*Client) ListComments

func (c *Client) ListComments(ctx context.Context, number int) ([]*forge.Comment, error)

ListComments returns all comments on the given issue.

func (*Client) ListFiles added in v0.1.10

func (c *Client) ListFiles(_ context.Context, path, ref string) ([]forge.FileEntry, error)

ListFiles returns the files and directories at the given path and ref. If path is empty, the repository root is listed. If ref is empty, the default branch HEAD is used.

func (*Client) ListIssues

func (c *Client) ListIssues(ctx context.Context, opts *forge.ListOptions) (issues []*forge.Issue, err error)

ListIssues returns issues matching the given filter options.

func (*Client) ListPullRequests added in v0.1.6

func (c *Client) ListPullRequests(ctx context.Context, opts *forge.ListPROptions) ([]*forge.PullRequest, error)

ListPullRequests returns pull requests matching the given filter options.

func (*Client) ListReviewComments added in v0.1.8

func (c *Client) ListReviewComments(ctx context.Context, prNumber int) ([]forge.ReviewComment, error)

ListReviewComments returns all inline review comments on a pull request.

func (*Client) MergePullRequest added in v0.1.6

func (c *Client) MergePullRequest(ctx context.Context, number int, method forge.MergeMethod, commitMsg string) error

MergePullRequest merges a pull request using the specified method.

func (*Client) ReadFile added in v0.1.10

func (c *Client) ReadFile(_ context.Context, path, ref string) ([]byte, error)

ReadFile returns the raw bytes of the file at the given path and ref. If ref is empty, the default branch HEAD is used.

func (*Client) RemoveLabel

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

RemoveLabel removes a single label from the given issue.

func (*Client) SearchCode added in v0.1.10

func (c *Client) SearchCode(_ context.Context, _ string) ([]forge.SearchResult, error)

SearchCode is not supported by the Gitea SDK v0.23.2 at the repo scope. It returns forge.ErrNotSupported so callers can surface a friendly message.

func (*Client) SearchIssues added in v0.1.21

func (c *Client) SearchIssues(ctx context.Context, opts *forge.SearchOptions) (issues []*forge.Issue, err error)

SearchIssues performs full-text search across issue titles and bodies using Gitea's keyword search parameter.

func (*Client) SetLabels

func (c *Client) SetLabels(ctx context.Context, number int, labels []string) error

SetLabels replaces all labels on the given issue.

func (*Client) SetPollInterval

func (c *Client) SetPollInterval(d time.Duration)

SetPollInterval configures the polling interval for Watch.

func (*Client) Unassign

func (c *Client) Unassign(ctx context.Context, number int, assignee string) error

Unassign removes an assignee from the given issue via read-modify-write. Gitea has no dedicated unassign endpoint; we read the current assignees, remove the target, and write back via EditIssue.

func (*Client) UpdateIssue

func (c *Client) UpdateIssue(ctx context.Context, number int, req *forge.UpdateIssueRequest) (issue *forge.Issue, err error)

UpdateIssue modifies an existing issue. Nil fields in the request are left unchanged.

func (*Client) Watch

func (c *Client) Watch(ctx context.Context, handler func(forge.Event)) error

Watch polls the Gitea API for issue changes and calls handler for each detected event. It blocks until the context is cancelled. The initial poll establishes baseline state; subsequent polls emit events for changes.

Jump to

Keyboard shortcuts

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