services

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReasonArchived  = "archived"          // the repository is archived and read-only
	ReasonExists    = "exists"            // a resource with the same identity already exists
	ReasonMerged    = "merged"            // the pull request is already merged
	ReasonClosed    = "closed"            // the pull request is closed
	ReasonDraft     = "draft"             // a draft pull request cannot be merged
	ReasonOwnReview = "own review"        // authors cannot approve or reject their own pull request
	ReasonNoChanges = "no changes"        // the head branch has no commits the base lacks
	ReasonDisabled  = "disabled"          // the workflow is disabled
	ReasonCompleted = "completed"         // the run already finished
	ReasonNotDone   = "not done"          // the run has not finished yet
	ReasonKeyInUse  = "key in use"        // the SSH key is registered already
	ReasonOwnsRepos = "owns repositories" // the user still owns repositories
	ReasonOwnsOther = "owns other"        // the user is still in organizations or owns packages
)

Reasons a ConflictError gives for refusing a request.

View Source
const (
	KindIssue = "issue"
	KindPull  = "pull"
)

Kinds of Issue: Gitea lists pull requests among issues.

View Source
const (
	UnitIssues = "issues"
	UnitPulls  = "pull requests"
)

Repository units that Gitea answers with a bare 404 when they are turned off.

View Source
const (
	MembershipPublic    = "public"
	MembershipConcealed = "concealed"
)

Membership visibilities.

Variables

View Source
var ErrJobNotStarted = errors.New("job not started")

ErrJobNotStarted reports a job without logs because no runner has started it.

View Source
var ErrMaxPages = errors.New("API pagination exceeded the page limit")

ErrMaxPages reports a paginated request that has more pages than APIOptions.MaxPages allows.

View Source
var ErrNoDispatch = errors.New("workflow has no workflow_dispatch trigger")

ErrNoDispatch reports a workflow that has no workflow_dispatch trigger.

View Source
var ErrRunScanExhausted = fmt.Errorf("time filters scanned %d runs without exhausting the history", maxRunScanPages*100)

ErrRunScanExhausted reports time filters that matched too few of the runs a scan may read.

View Source
var ExternalTeamUnits = []string{"repo.ext_issues", "repo.ext_wiki"}

ExternalTeamUnits link to external trackers and wikis, which teams can at most read.

View Source
var RunStatuses = []string{"queued", "in_progress", "waiting", "requested", "pending", "action_required", "completed", "success", "failure", "cancelled", "skipped", "timed_out", "neutral"} //nolint:misspell // Gitea API spelling.

RunStatuses are the values Gitea accepts as run status filters.

View Source
var TeamUnits = []string{"repo.code", "repo.issues", "repo.pulls", "repo.releases", "repo.wiki", "repo.projects", "repo.packages", "repo.actions"}

TeamUnits are the repository units a team grants access to, in the order Gitea shows them.

View Source
var WebhookEventGroups = map[string][]string{
	"issues":       {"issue_assign", "issue_comment", "issue_label", "issue_milestone"},
	"pull_request": {"pull_request_assign", "pull_request_comment", "pull_request_label", "pull_request_milestone", "pull_request_review", "pull_request_review_request", "pull_request_sync"},
}

WebhookEventGroups are the events that sending issues or pull_request enables besides that event.

View Source
var WebhookEvents = []string{
	"create", "delete", "fork", "push",
	"issues", "issues_only", "issue_assign", "issue_label", "issue_milestone", "issue_comment",
	"pull_request", "pull_request_only", "pull_request_assign", "pull_request_label", "pull_request_milestone",
	"pull_request_comment", "pull_request_review", "pull_request_sync", "pull_request_review_request",
	"wiki", "repository", "release", "package", "status", "workflow_run", "workflow_job",
}

WebhookEvents are the events that webhooks accept. issues and pull_request select every event of their group; issues_only and pull_request_only select the events of the issue or pull request itself.

View Source
var WebhookTypes = []string{"gitea", "gogs", "slack", "discord", "dingtalk", "telegram", "msteams", "feishu", "matrix", "wechatwork", "packagist"}

WebhookTypes are the adapters that deliver webhooks.

Functions

func ActionValueName

func ActionValueName(name string) string

ActionValueName is the name Gitea stores a secret or variable under: names are upper-cased.

func AddDraftPrefix

func AddDraftPrefix(title string) string

AddDraftPrefix returns title with a "WIP: " prefix, or title unchanged if it already carries a recognized draft prefix.

func Classify

func Classify(err error, kind, key, scope string) error

Classify names the resource of a failed request: a 404 or an unknown user becomes a NotFoundError, a refusal Gitea explains a ConflictError. Other errors are returned unchanged.

func CurrentAccount

func CurrentAccount(ctx context.Context, client *transport.Client) (string, error)

CurrentAccount verifies the credential against the selected Gitea installation and returns the authenticated login. It asks the server once per client and Sudo user.

func IsForbidden

func IsForbidden(err error) bool

IsForbidden reports whether err is a 403 response.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err is a 404 response.

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized reports whether err is a 401 response.

func MatchAccount

func MatchAccount(selected, authenticated string) bool

MatchAccount reports whether selected matches the authenticated login. An empty selection accepts any account.

func MaxPageSize

func MaxPageSize(ctx context.Context, client *transport.Client) (int, error)

MaxPageSize returns the most items the instance returns for one page of a listing.

func OfficialApprovals

func OfficialApprovals(reviews []Review, skipStale bool) int64

OfficialApprovals counts the reviewers whose latest decisive review is an official approval that was not dismissed, nor stale with skipStale.

func OwnerExists

func OwnerExists(ctx context.Context, client *transport.Client, name string) error

OwnerExists fails with a *NotFoundError when no user or organization is called name.

func RequestedReviewers

func RequestedReviewers(reviews []Review) (users, teams []string)

RequestedReviewers returns the users and teams with an outstanding review request: each user whose latest review is a request, and each team with a request. Gitea's requested_reviewers also lists users who reviewed, even after their request was canceled, so the reviews decide.

func ReviewDecision

func ReviewDecision(reviews []Review, requested bool) string

ReviewDecision summarizes reviews like gh: changes_requested when a reviewer's latest decisive review requests changes, else approved when one approves, else review_required while reviews are requested, else "". Comment reviews are not decisive (as in gh and Gitea) and dismissed reviews do not count.

func ServerVersion

func ServerVersion(ctx context.Context, client *transport.Client) (string, error)

ServerVersion returns the Gitea version of the instance.

func StripDraftPrefix

func StripDraftPrefix(title string) string

StripDraftPrefix returns title with any recognized leading draft prefix removed, or title unchanged if no prefix is present.

func SuccessfulRun

func SuccessfulRun(run Run) bool

SuccessfulRun recognizes a successful terminal run result.

func Tally

func Tally(items []Check) (failing, pending, passed int)

Tally counts checks by outcome.

func TokenScopes

func TokenScopes(ctx context.Context, client *transport.Client) ([]string, error)

TokenScopes returns the scopes of the access token that client authenticates with, such as "all" or "write:repository". Gitea answers only for access tokens.

func UnitAccess

func UnitAccess(unit string) []string

UnitAccess lists the access levels a team can have to unit, or nil for an unknown unit.

func UnitPolicy

func UnitPolicy(access string) map[string]string

UnitPolicy grants access, read or write, to every unit, and read to the external units.

Types

type API

type API struct{ Client *transport.Client }

API provides the raw escape hatch while keeping credentials scoped to one instance.

func (API) Visit

func (s API) Visit(ctx context.Context, options APIOptions, visit func(*http.Response) error) error

Visit delivers responses in order and closes each body after the visitor. A response outside 2xx is still visited, then ends the visit as an *transport.APIError. Pagination follows only scoped links and never retries a mutation.

type APIOptions

type APIOptions struct {
	Endpoint string
	Method   string
	Body     io.Reader
	Headers  http.Header
	Paginate bool
	MaxPages int
}

APIOptions describes a raw request and its bounded pagination policy.

type AccountStatus

type AccountStatus struct {
	Host string `json:"host"`
	User string `json:"user"`
	// Repository is the repository the summary is scoped to, empty for all repositories.
	Repository     string       `json:"repository"`
	AssignedIssues []SearchItem `json:"assigned_issues"`
	PullRequests   PullStatus   `json:"pull_requests"`
	// Mentions are the open issues and pull requests that mention the account.
	Mentions []SearchItem `json:"mentions"`
	// RunsRepository is the repository whose failing runs are listed, when RunsIncluded.
	RunsRepository string `json:"runs_repository"`
	FailingRuns    []Run  `json:"failing_runs"`
	RunsIncluded   bool   `json:"runs_included"`
}

AccountStatus is an account summary with optional repository Actions results.

type ActionScope

type ActionScope struct {
	Repository, Organization string
	Account                  bool
}

ActionScope identifies exactly one repository, organization, or account scope.

func (ActionScope) String

func (s ActionScope) String() string

String names the scope for people: "alice/project", "organization acme" or "your account".

type ActionSecret

type ActionSecret struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	CreatedAt   string `json:"created_at"`
}

ActionSecret describes a secret without containing its value. CreatedAt is empty for a secret that was just set, as Gitea does not return it.

type ActionSecrets

type ActionSecrets struct {
	Client *transport.Client
	Scope  ActionScope
}

ActionSecrets manages scoped Actions secrets without returning secret data.

func (ActionSecrets) Delete

func (s ActionSecrets) Delete(ctx context.Context, name string) error

Delete removes only the named secret in the selected scope.

func (ActionSecrets) ListPage

func (s ActionSecrets) ListPage(ctx context.Context, limit, page int) (Page[ActionSecret], error)

ListPage lists a page of secrets, with what the server reports about the other pages.

func (ActionSecrets) Set

func (s ActionSecrets) Set(ctx context.Context, name, value, description string) (ActionSecret, error)

Set creates or replaces a secret; the API's PUT operation defines upsert semantics. The result names the secret as Gitea stores it.

type ActionVariable

type ActionVariable struct {
	Name        string `json:"name"`
	Value       string `json:"value"`
	Description string `json:"description"`
}

ActionVariable contains one non-secret workflow variable.

type ActionVariables

type ActionVariables struct {
	Client *transport.Client
	Scope  ActionScope
}

ActionVariables manages scoped non-secret Actions variables.

func (ActionVariables) Delete

func (s ActionVariables) Delete(ctx context.Context, name string) error

Delete removes only the named variable in the selected scope.

func (ActionVariables) ListPage

func (s ActionVariables) ListPage(ctx context.Context, limit, page int) (Page[ActionVariable], error)

ListPage lists a page of variables, with what the server reports about the other pages.

func (ActionVariables) Set

func (s ActionVariables) Set(ctx context.Context, name, value string, newDescription *string) (ActionVariable, error)

Set chooses create or update from an authoritative read. A nil description keeps the one of an existing variable, as Gitea replaces it on every update.

func (ActionVariables) View

View retrieves one variable.

type Actions

type Actions struct {
	Client     *transport.Client
	Repository string
}

Actions implements repository workflow and run operations.

func (Actions) AllArtifacts

func (s Actions) AllArtifacts(ctx context.Context, run int64) ([]Artifact, error)

AllArtifacts lists every artifact belonging to a run.

func (Actions) Artifacts

func (s Actions) Artifacts(ctx context.Context, run int64, limit, page int) (Page[Artifact], error)

Artifacts lists one page of artifacts belonging to a run, with their total number.

func (Actions) CancelRun

func (s Actions) CancelRun(ctx context.Context, id int64, force bool) (Run, error)

CancelRun requests cancellation without deleting the run or its history. Force cancellation is an explicit operation for unresponsive runners.

func (Actions) DeleteRun

func (s Actions) DeleteRun(ctx context.Context, id int64) error

DeleteRun removes the selected run.

func (Actions) Dispatch

func (s Actions) Dispatch(ctx context.Context, id, ref string, inputs map[string]string) (DispatchResult, error)

Dispatch triggers a workflow and reports the run it created.

func (Actions) DownloadArtifact

func (s Actions) DownloadArtifact(ctx context.Context, id int64) (io.ReadCloser, error)

DownloadArtifact streams an artifact ZIP, accepting a scoped signed redirect.

func (Actions) FindWorkflow

func (s Actions) FindWorkflow(ctx context.Context, raw string) (Workflow, error)

FindWorkflow returns the workflow that raw names in the repository: its file name, path, file name without extension, or name, matched exactly and then case-insensitively.

func (Actions) FollowJobLogs

func (s Actions) FollowJobLogs(ctx context.Context, run, id int64, interval time.Duration, emit func([]byte) error) error

FollowJobLogs emits only newly appended bytes and stops when the job completes. A shorter snapshot fails rather than silently mixing logs from different attempts.

func (Actions) JobLogs

func (s Actions) JobLogs(ctx context.Context, id int64) (io.ReadCloser, error)

JobLogs streams a job's plain-text logs within the selected instance. A job that has not started fails with ErrJobNotStarted.

func (Actions) Jobs

func (s Actions) Jobs(ctx context.Context, run int64) ([]Job, error)

Jobs lists every job in the selected run.

func (Actions) JobsPage

func (s Actions) JobsPage(ctx context.Context, run int64, limit, page int) (Page[Job], error)

JobsPage lists a page of jobs in the selected run.

func (Actions) NameRun

func (s Actions) NameRun(ctx context.Context, run Run) Run

NameRun names a run that a mutation returned after its workflow; it stays as is when the workflows cannot be listed.

func (Actions) Rerun

func (s Actions) Rerun(ctx context.Context, id, job int64, failedOnly bool) error

Rerun schedules another attempt of a run, restricted to its failed jobs with failedOnly, or of one job when job is not 0.

func (Actions) Run

func (s Actions) Run(ctx context.Context, id int64) (Run, error)

Run retrieves one Actions run.

func (Actions) RunDetails

func (s Actions) RunDetails(ctx context.Context, id int64) (Run, error)

RunDetails retrieves one run with its jobs, named after its workflow.

func (Actions) RunJob

func (s Actions) RunJob(ctx context.Context, run, id int64) (Job, error)

RunJob retrieves the job id of run, including a job of an earlier attempt, which Jobs no longer lists after a rerun.

func (Actions) RunLogsArchive

func (s Actions) RunLogsArchive(ctx context.Context, run int64) (io.ReadCloser, error)

RunLogsArchive streams the server's ZIP archive without extracting its entries. A run without logs, such as one that never started, is reported as not found. TODO(sdk): GetRepoRunLogsReader cannot follow the redirect to object storage that serves logs directly.

func (Actions) Runs

func (s Actions) Runs(ctx context.Context, opts RunListOptions) ([]Run, error)

Runs lists a page of runs, newest first.

func (Actions) RunsPage

func (s Actions) RunsPage(ctx context.Context, opts RunListOptions) (Page[Run], error)

RunsPage lists a page of runs like Runs, named after their workflows, with the number of runs the filters match when the server counts them.

func (Actions) SetWorkflowEnabled

func (s Actions) SetWorkflowEnabled(ctx context.Context, id string, enabled bool) error

SetWorkflowEnabled updates whether a workflow can run.

func (Actions) WaitForFirstJob

func (s Actions) WaitForFirstJob(ctx context.Context, run int64, interval time.Duration) (Job, error)

WaitForFirstJob polls a freshly dispatched run until the server has created its first job.

func (Actions) Watch

func (s Actions) Watch(ctx context.Context, id int64, interval time.Duration, update func(Run) error) (Run, error)

Watch polls a run with its jobs every interval until it completes, reporting each poll to update, and returns the completed run. When it fails, such as when ctx expires, it returns the run as last polled.

func (Actions) Workflow

func (s Actions) Workflow(ctx context.Context, id string) (Workflow, error)

Workflow retrieves one workflow definition by its file name.

func (Actions) WorkflowFile

func (s Actions) WorkflowFile(ctx context.Context, workflow Workflow, ref string) ([]byte, error)

WorkflowFile returns the workflow's YAML definition at ref, a branch, tag or commit, or on the default branch when ref is empty.

func (Actions) Workflows

func (s Actions) Workflows(ctx context.Context) ([]Workflow, error)

Workflows lists the repository workflow definitions.

type AdminUser

type AdminUser struct {
	ID            int64  `json:"id"`
	Username      string `json:"username"`
	Email         string `json:"email"`
	FullName      string `json:"full_name"`
	Description   string `json:"description"`
	Website       string `json:"website"`
	Location      string `json:"location"`
	URL           string `json:"url"`
	Admin         bool   `json:"admin"`
	Active        bool   `json:"active"`
	Restricted    bool   `json:"restricted"`
	ProhibitLogin bool   `json:"prohibit_login"`
	Visibility    string `json:"visibility"`
	CreatedAt     string `json:"created_at"`
}

AdminUser is the explicit account-management result, without authentication secrets.

type AdminUserOptions

type AdminUserOptions struct {
	Email                   *string `json:"email,omitempty"`
	FullName                *string `json:"full_name,omitempty"`
	Description             *string `json:"description,omitempty"`
	Website                 *string `json:"website,omitempty"`
	Location                *string `json:"location,omitempty"`
	Visibility              *string `json:"visibility,omitempty"`
	Password                string  `json:"password,omitempty"`
	Admin                   *bool   `json:"admin,omitempty"`
	Active                  *bool   `json:"active,omitempty"`
	Restricted              *bool   `json:"restricted,omitempty"`
	ProhibitLogin           *bool   `json:"prohibit_login,omitempty"`
	MustChangePassword      *bool   `json:"must_change_password,omitempty"`
	AllowGitHook            *bool   `json:"allow_git_hook,omitempty"`
	AllowImportLocal        *bool   `json:"allow_import_local,omitempty"`
	AllowCreateOrganization *bool   `json:"allow_create_organization,omitempty"`
	MaxRepoCreation         *int    `json:"max_repo_creation,omitempty"`
}

AdminUserOptions distinguishes omitted fields from explicit empty or false values.

type AdminUsers

type AdminUsers struct{ Client *transport.Client }

AdminUsers provides administrator account operations.

func (AdminUsers) Create

func (s AdminUsers) Create(ctx context.Context, username string, opts AdminUserOptions) (AdminUser, error)

Create creates an account, then applies administrative fields unavailable during creation.

func (AdminUsers) Delete

func (s AdminUsers) Delete(ctx context.Context, username string, purge bool) error

Delete removes an account. Gitea refuses to delete users who own repositories or organizations unless purge also deletes what they own.

func (AdminUsers) Edit

func (s AdminUsers) Edit(ctx context.Context, username string, opts AdminUserOptions) (AdminUser, error)

Edit preserves the authentication identity while updating account properties.

func (AdminUsers) List

func (s AdminUsers) List(ctx context.Context, query string, limit, page int) (Page[AdminUser], error)

List returns a page of the users whose username, full name or email contains query, or of every user without one.

func (AdminUsers) Search

func (s AdminUsers) Search(ctx context.Context, query string, limit int) ([]AdminUser, error)

Search finds accounts whose name contains query; unlike List it needs no administrator rights.

func (AdminUsers) View

func (s AdminUsers) View(ctx context.Context, username string) (AdminUser, error)

View retrieves one account.

type AmbiguousError

type AmbiguousError struct {
	Kind, Key, Scope string
	IDs              []int64
	// Hint replaces the advice to pass an ID where IDs do not select the resource.
	Hint string
}

AmbiguousError reports a name that matches several resources.

func (*AmbiguousError) Error

func (e *AmbiguousError) Error() string

type Artifact

type Artifact struct {
	ID        int64   `json:"id"`
	Name      string  `json:"name"`
	Size      int64   `json:"size_in_bytes"`
	URL       string  `json:"url"`
	Expired   bool    `json:"expired"`
	CreatedAt string  `json:"created_at"`
	UpdatedAt string  `json:"updated_at"`
	ExpiresAt *string `json:"expires_at"`
}

Artifact is the stable metadata for a downloadable Actions artifact.

type Assignee

type Assignee struct {
	Username string `json:"username"`
	FullName string `json:"full_name"`
}

Assignee is a user that can be assigned on repository issues.

type Board

type Board struct {
	*gitea.Project
	// contains filtered or unexported fields
}

Board is a project with its default column and the column that holds each issue on it, by the issue's global ID.

type Branch

type Branch struct {
	Name              string `json:"name"`
	SHA               string `json:"sha"`
	Message           string `json:"message"`
	UpdatedAt         string `json:"updated_at"`
	Protected         bool   `json:"protected"`
	RequiredApprovals int64  `json:"required_approvals"`
	CanPush           bool   `json:"can_push"`
	CanMerge          bool   `json:"can_merge"`
}

Branch describes a remote branch, its last commit and its protection.

type Branches

type Branches struct{ Client *transport.Client }

Branches operates on remote branches and protection rules.

func (Branches) Create

func (s Branches) Create(ctx context.Context, repo, branch, source string) (Branch, error)

Create creates a branch from source, a branch, tag or commit, or from the default branch.

func (Branches) Delete

func (s Branches) Delete(ctx context.Context, repo, branch string) error

Delete removes a remote branch.

func (Branches) EditProtection

func (s Branches) EditProtection(ctx context.Context, repo string, rule Protection, changes ProtectionChanges) error

EditProtection changes the settings of the existing rule named rule.Rule that changes selects, and keeps the others. Pushers replace those who may push directly. It fails with a *DroppedPushersError when the rule leaves out some of its pushers.

func (Branches) Find

func (s Branches) Find(ctx context.Context, repo, branch string) (Branch, error)

Find retrieves a remote branch, naming repo instead when that is what is missing.

func (Branches) ListPage

func (s Branches) ListPage(ctx context.Context, repo string, limit, page int) (Page[Branch], error)

ListPage lists a page of branches, with whether more follow and how many there are.

func (Branches) Protect

func (s Branches) Protect(ctx context.Context, repo string, rule Protection) (bool, error)

Protect adds a protection rule. It reports false without a change when the rule exists already, and a *DroppedPushersError when the rule leaves out some of its pushers.

func (Branches) Rename

func (s Branches) Rename(ctx context.Context, repo, oldName, newName string) error

Rename renames a remote branch.

func (Branches) RequireAll

func (s Branches) RequireAll(ctx context.Context, repo string, branches []string) error

RequireAll fails unless every branch exists in repo, naming each one that does not, or repo when that is what is missing.

func (Branches) Unprotect

func (s Branches) Unprotect(ctx context.Context, repo, rule string) (bool, error)

Unprotect removes the protection rule named rule. It reports false when there is none.

func (Branches) View

func (s Branches) View(ctx context.Context, repo, branch string) (Branch, error)

View retrieves a remote branch of a repository the caller knows to exist: a missing repository reads as a missing branch, without the request of Find that tells them apart.

type CapabilityError

type CapabilityError struct{ Feature, Reason string }

CapabilityError reports an operation absent from the Gitea REST contract.

func (*CapabilityError) Error

func (e *CapabilityError) Error() string

type Check

type Check struct {
	SHA         string `json:"sha"`
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	State       string `json:"state"`
	Description string `json:"description"`
	URL         string `json:"url"`
	CreatedAt   string `json:"created_at"`
	UpdatedAt   string `json:"updated_at"`
}

Check represents the latest status of one commit context.

func (Check) Passed

func (c Check) Passed() bool

Passed reports whether the check finished without blocking a merge; Gitea counts skipped as success.

func (Check) Pending

func (c Check) Pending() bool

Pending reports whether the check has not finished yet.

type Comment

type Comment struct {
	ID        int64  `json:"id"`
	Body      string `json:"body"`
	URL       string `json:"url"`
	Author    string `json:"author"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
	// IssueNumber is the issue or pull request the comment is on.
	IssueNumber int64 `json:"issue_number"`
	// Pull reports a comment on a pull request rather than an issue.
	Pull bool `json:"-"`
}

Comment is the public representation shared by issue and pull request comments.

type Comments

type Comments struct {
	Client     *transport.Client
	Repository string
}

Comments implements discussion comments under their owning repository resource.

func (Comments) Create

func (s Comments) Create(ctx context.Context, n int64, body string) (Comment, error)

Create adds a comment to an issue or pull request.

func (Comments) Delete

func (s Comments) Delete(ctx context.Context, id int64) error

Delete removes a repository comment.

func (Comments) Edit

func (s Comments) Edit(ctx context.Context, id int64, body string) (Comment, error)

Edit replaces the body of a repository comment.

func (Comments) List

func (s Comments) List(ctx context.Context, n int64) ([]Comment, error)

List returns every discussion comment; the API does not paginate this collection.

func (Comments) Page

func (s Comments) Page(ctx context.Context, n int64, limit, page int) (Page[Comment], error)

Page applies CLI pagination to the unpaginated comment collection.

func (Comments) UploadAttachment

func (s Comments) UploadAttachment(ctx context.Context, id int64, name string, input io.Reader) (IssueAttachment, error)

UploadAttachment streams a file to comment id.

func (Comments) View

func (s Comments) View(ctx context.Context, id int64) (Comment, error)

View retrieves a comment by its repository-scoped ID.

type ConflictError

type ConflictError struct {
	// Reason is one of the Reason constants.
	Reason string
	// Kind, Key and Scope name the refused resource like NotFoundError; any may be empty.
	Kind, Key, Scope string
	// Hint is the next step, such as "use gt release edit v1.0"; callers add it.
	Hint string
	// Err is the underlying *transport.APIError.
	Err error
}

ConflictError reports a request the current state of a resource refuses, such as closing a merged pull request or writing to an archived repository.

func (*ConflictError) Error

func (e *ConflictError) Error() string

func (*ConflictError) Unwrap

func (e *ConflictError) Unwrap() error

type CreateSelectables

type CreateSelectables struct {
	CanPush    bool
	Assignees  []string
	Milestones []Milestone
	Labels     []Label
}

CreateSelectables are the metadata choices offered by forms. Where they depend on push access, the lists stay empty unless CanPush.

type DeployKey

type DeployKey struct {
	ID          int64  `json:"id"`
	Title       string `json:"title"`
	Key         string `json:"key"`
	Fingerprint string `json:"fingerprint"`
	ReadOnly    bool   `json:"read_only"`
	CreatedAt   string `json:"created_at"`
}

DeployKey is an SSH key that grants access to one repository.

type DeployKeys

type DeployKeys struct {
	Client     *transport.Client
	Repository string
}

DeployKeys manages the deploy keys of a repository.

func (DeployKeys) Create

func (s DeployKeys) Create(ctx context.Context, title, key string, readOnly bool) (DeployKey, error)

Create adds a deploy key, which can push unless readOnly.

func (DeployKeys) Delete

func (s DeployKeys) Delete(ctx context.Context, id int64) error

Delete removes one deploy key.

func (DeployKeys) List

func (s DeployKeys) List(ctx context.Context, limit, page int) (Page[DeployKey], error)

List returns a page of the repository's deploy keys.

func (DeployKeys) View

func (s DeployKeys) View(ctx context.Context, id int64) (DeployKey, error)

View retrieves one deploy key.

type DiscussionSearchOptions

type DiscussionSearchOptions struct {
	Query, State, Owner, Team, Author, Labels, Milestones           string
	Since, Before                                                   *time.Time
	Pulls, Assigned, Authored, Mentioned, ReviewRequested, Reviewed bool
	Limit, Page                                                     int
}

DiscussionSearchOptions specifies issue or pull request filters.

type DispatchResult

type DispatchResult struct {
	ID  int64  `json:"id"`
	URL string `json:"url,omitempty"`
}

DispatchResult identifies a workflow run created by dispatch when the server returns details.

type DroppedPushersError

type DroppedPushersError struct {
	Repository, Rule string
	Users, Teams     []string
	// Nobody is set when Gitea dropped every pusher: the rule then lets nobody push.
	Nobody bool
	// Updated is set when an existing rule was changed rather than a new one created.
	Updated bool
}

DroppedPushersError reports the users and teams that Gitea left out of a new protection rule, which it does for those that cannot write to the repository.

func (*DroppedPushersError) Error

func (e *DroppedPushersError) Error() string

type ForkOptions

type ForkOptions struct{ Organization, Name string }

ForkOptions places a fork: under Organization instead of the account, and named Name instead of the forked repository's name.

type InlineComment

type InlineComment struct {
	Path    string `json:"path"`
	Body    string `json:"body"`
	OldLine int64  `json:"old_position"`
	NewLine int64  `json:"new_position"`
}

InlineComment supplies an explicit file position for review creation.

func (InlineComment) Validate

func (c InlineComment) Validate() error

Validate requires a path, a body, and exactly one positive line position.

type Issue

type Issue struct {
	Author    string          `json:"author"`
	Labels    []Label         `json:"labels"`
	Ref       string          `json:"ref"`
	ID        int64           `json:"id"`
	Number    int64           `json:"number"`
	Kind      string          `json:"kind"`
	Title     string          `json:"title"`
	Body      string          `json:"body"`
	URL       string          `json:"url"`
	State     string          `json:"state"`
	CreatedAt string          `json:"created_at"`
	UpdatedAt string          `json:"updated_at"`
	Deadline  *string         `json:"due_date"`
	Assignees []string        `json:"assignees"`
	Milestone *IssueMilestone `json:"milestone"`
	Comments  int64           `json:"comments"`
}

Issue is the stable command representation of an issue.

type IssueAttachment

type IssueAttachment ReleaseAsset

IssueAttachment describes an attachment owned by an issue or pull request.

type IssueCreateSelectables

type IssueCreateSelectables struct {
	CreateSelectables
	Templates []IssueTemplate
}

IssueCreateSelectables adds repository issue templates to the create form choices.

type IssueDependencies

type IssueDependencies struct {
	BlockedBy, Blocks []IssueReference
}

IssueDependencies lists the issues blocking one issue and the issues it blocks.

type IssueEdit

type IssueEdit struct {
	Labels         *[]int64         `json:"-"`
	Ref            *string          `json:"ref,omitempty"`
	Title          *string          `json:"title,omitempty"`
	Body           *string          `json:"body,omitempty"`
	Assignees      *[]string        `json:"assignees,omitempty"`
	Milestone      *int64           `json:"milestone,omitempty"`
	Deadline       *time.Time       `json:"due_date,omitempty"`
	RemoveDeadline *bool            `json:"unset_due_date,omitempty"`
	Changes        *MetadataChanges `json:"-"`
}

IssueEdit distinguishes omitted fields from explicit clears.

type IssueLabelCatalog

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

IssueLabelCatalog resolves the label names of issue flags against the repository's labels and those its organization shares.

func (IssueLabelCatalog) Resolve

func (c IssueLabelCatalog) Resolve(names []string) ([]int64, error)

Resolve maps names to label IDs. Duplicate names require an explicit repo: or org: scope to avoid choosing a different label.

type IssueMilestone

type IssueMilestone struct {
	ID    int64  `json:"id"`
	Title string `json:"title"`
}

IssueMilestone identifies the milestone associated with an issue or pull request.

type IssueOptions

type IssueOptions struct {
	Ref       string     `json:"ref,omitempty"`
	Title     string     `json:"title"`
	Body      string     `json:"body"`
	Assignees []string   `json:"assignees,omitempty"`
	Labels    []int64    `json:"labels,omitempty"`
	Milestone int64      `json:"milestone,omitempty"`
	Deadline  *time.Time `json:"due_date,omitempty"`
}

IssueOptions supplies issue creation input.

type IssueReference

type IssueReference struct {
	Repository string `json:"repository"`
	Number     int64  `json:"number"`
}

IssueReference identifies an issue that may live in another repository. Number is zero for issues the account cannot read.

type IssueTemplate

type IssueTemplate struct {
	Name, About, Title, Content string
	Labels                      []string
	Form                        bool
	// Ref is the branch or tag the template sets on new issues.
	Ref string
	// FileName is the path of the template in the repository, which the new-issue page takes.
	FileName string
}

IssueTemplate is a repository issue template used to seed create forms.

type Issues

type Issues struct {
	Client     *transport.Client
	Repository string
	// Pulls is set when the numbers name pull requests, which Gitea serves through the issue
	// endpoints also when issues are turned off: failures then name the pull request.
	Pulls bool
}

Issues implements repository issue operations.

func (Issues) Attachment

func (s Issues) Attachment(ctx context.Context, number, id int64) (IssueAttachment, error)

Attachment retrieves metadata for one attachment in its owning issue.

func (Issues) Attachments

func (s Issues) Attachments(ctx context.Context, number int64, limit, page int) (Page[IssueAttachment], error)

Attachments paginates the server's unpaginated attachment collection locally.

func (Issues) Create

func (s Issues) Create(ctx context.Context, options IssueOptions) (Issue, error)

Create opens an issue.

func (Issues) CreateSelectables

func (s Issues) CreateSelectables(ctx context.Context) (IssueCreateSelectables, error)

CreateSelectables concurrently loads templates, assignees, milestones and labels. The metadata choices do not depend on push access, which is all the permissions of a repository tell: people who can write to the issues set metadata without it, and issue create names what Gitea left out for others. CanPush stays false.

func (Issues) DeleteAttachment

func (s Issues) DeleteAttachment(ctx context.Context, number, id int64) error

DeleteAttachment removes one attachment from its owning issue.

func (Issues) Dependencies

func (s Issues) Dependencies(ctx context.Context, number int64) (IssueDependencies, error)

Dependencies reads both dependency directions; servers or repositories without dependency support report none.

func (Issues) DownloadAttachment

func (s Issues) DownloadAttachment(ctx context.Context, number, id int64) (IssueAttachment, func() (io.ReadCloser, error), error)

DownloadAttachment retrieves an attachment's metadata and returns a function that opens its content, scoped to its instance and issue. Nothing is downloaded until that function is called, so callers can refuse or skip the download first.

func (Issues) Edit

func (s Issues) Edit(ctx context.Context, n int64, opts IssueEdit) (Issue, error)

Edit updates only supplied issue fields.

func (Issues) EditSelectables

func (s Issues) EditSelectables(ctx context.Context) (CreateSelectables, error)

EditSelectables loads the assignees, milestones and labels the edit form offers. Like those of CreateSelectables, they do not depend on push access, and issue edit names what Gitea left out for people who cannot write to the issues. CanPush stays false.

func (Issues) IssueTemplates

func (s Issues) IssueTemplates(ctx context.Context) ([]IssueTemplate, error)

IssueTemplates lists repository issue templates; null responses become an empty list.

func (Issues) Kind

func (s Issues) Kind(ctx context.Context, number int64) (string, error)

Kind returns whether number is an issue or a pull request, KindIssue or KindPull, in one request. It is "" for a number Gitea does not show, such as an issue of a repository that uses an external tracker.

func (Issues) List

func (s Issues) List(ctx context.Context, opts ListOptions) ([]Issue, bool, error)

List returns a page of issues, even when the server caps its page size below the limit, and reports whether more issues follow.

func (Issues) ListPage

func (s Issues) ListPage(ctx context.Context, opts ListOptions) (Page[Issue], error)

ListPage is List with the number of issues that match, as the server counts them.

func (Issues) RemoveMilestone

func (s Issues) RemoveMilestone(ctx context.Context, n int64, milestone Milestone) (Issue, error)

RemoveMilestone clears the milestone of issue n when it is milestone. It refuses to clear an issue belonging to another milestone or to none, returning it with a *NotInMilestoneError.

func (Issues) RenameAttachment

func (s Issues) RenameAttachment(ctx context.Context, number, id int64, name string) (IssueAttachment, error)

RenameAttachment changes the filename without replacing its content.

func (Issues) Search

func (s Issues) Search(ctx context.Context, opts DiscussionSearchOptions) ([]SearchItem, error)

Search searches one repository or accessible repositories across the selected instance.

func (Issues) SearchPage

func (s Issues) SearchPage(ctx context.Context, opts DiscussionSearchOptions) (Page[SearchItem], error)

SearchPage is Search with what the server reports about further results.

func (Issues) SetBlockedBy

func (s Issues) SetBlockedBy(ctx context.Context, n int64, blocker IssueReference, block bool) error

SetBlockedBy makes issue n blocked by issue blocker, which may belong to another repository where the instance allows that, or with block false lifts that dependency. Like other additions and removals, adding a dependency that exists or removing one that does not changes nothing.

func (Issues) SetState

func (s Issues) SetState(ctx context.Context, number int64, state string) (Issue, error)

SetState updates only the selected issue state.

func (Issues) Timeline

func (s Issues) Timeline(ctx context.Context, n int64, limit, page int) (Page[TimelineEvent], error)

Timeline returns a page of the timeline of issue or pull request n, oldest first. Gitea sends no Link header for the timeline and counts only the returned page in X-Total-Count, so a page that may continue asks for the one event after it.

func (Issues) UploadAttachment

func (s Issues) UploadAttachment(ctx context.Context, number int64, name string, input io.Reader) (IssueAttachment, error)

UploadAttachment streams a file to its owning issue or pull request.

func (Issues) View

func (s Issues) View(ctx context.Context, number int64) (Issue, error)

View retrieves one issue.

type Job

type Job struct {
	RunAttempt  int64    `json:"run_attempt"`
	ID          int64    `json:"id"`
	Name        string   `json:"name"`
	Status      string   `json:"status"`
	Conclusion  string   `json:"conclusion"`
	URL         string   `json:"url"`
	Labels      []string `json:"labels"`
	CreatedAt   string   `json:"created_at"`
	StartedAt   *string  `json:"started_at"`
	CompletedAt *string  `json:"completed_at"`
	Steps       []Step   `json:"steps"`
}

Job identifies one workflow job without exposing server-specific metadata. StartedAt and CompletedAt are nil until the job starts and completes.

func (Job) Completed

func (j Job) Completed() bool

Completed reports whether the job finished, whatever its conclusion.

func (Job) Started

func (j Job) Started() bool

Started reports whether the job has started, so that it has logs.

type Label

type Label struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Color       string `json:"color"`
	Description string `json:"description"`
	Exclusive   bool   `json:"exclusive"`
	Archived    bool   `json:"is_archived"`
}

Label is a repository or organization label.

type LabelOptions

type LabelOptions struct {
	Name        *string `json:"name,omitempty"`
	Color       *string `json:"color,omitempty"`
	Description *string `json:"description,omitempty"`
	Exclusive   *bool   `json:"exclusive,omitempty"`
	Archived    *bool   `json:"is_archived,omitempty"`
}

LabelOptions distinguishes omitted label fields during edits.

func (LabelOptions) KeepArchived

func (opts LabelOptions) KeepArchived(current Label) LabelOptions

KeepArchived returns opts with the archived state of current unless opts sets one: Gitea unarchives a label whose edit leaves is_archived out.

type Labels

type Labels struct {
	Client                   *transport.Client
	Repository, Organization string
}

Labels implements explicitly scoped label operations.

func (Labels) All

func (s Labels) All(ctx context.Context) ([]Label, error)

All returns every label in the scope.

func (Labels) Create

func (s Labels) Create(ctx context.Context, opts LabelOptions) (Label, error)

Create creates one label.

func (Labels) CreateUnique

func (s Labels) CreateUnique(ctx context.Context, existing []Label, opts LabelOptions, update bool) (Label, bool, error)

CreateUnique creates a label unless existing has one with its name, ignoring case: Gitea would create a second label that name filters cannot tell apart. Then update edits that label, keeping its name, or CreateUnique fails. It reports whether it updated a label.

func (Labels) Delete

func (s Labels) Delete(ctx context.Context, id int64) error

Delete deletes one scoped label.

func (Labels) Edit

func (s Labels) Edit(ctx context.Context, id int64, opts LabelOptions) (Label, error)

Edit updates only explicitly supplied fields.

func (Labels) EditUnique

func (s Labels) EditUnique(ctx context.Context, existing []Label, current Label, opts LabelOptions) (Label, error)

EditUnique edits current like Edit, keeping its archived state, but refuses to rename it to the name of another label among existing, the labels of the scope, ignoring case, which CreateUnique refuses too: names would no longer address either label.

func (Labels) Find

func (s Labels) Find(ctx context.Context, raws []string, byName bool) ([]Label, error)

Find returns the labels of the scope that raws address, each by ID or name; byName matches numeric values as names only.

func (Labels) FindIn

func (s Labels) FindIn(items []Label, raw string, byName bool) (Label, error)

FindIn returns the label among items, the labels of the scope, that raw addresses like Find.

func (Labels) IssueCatalog

func (s Labels) IssueCatalog(ctx context.Context) (IssueLabelCatalog, error)

IssueCatalog loads the labels that issue label names can select.

func (Labels) List

func (s Labels) List(ctx context.Context, limit, page int) ([]Label, error)

List returns scoped labels without merging unrelated organization labels.

func (Labels) ListPage

func (s Labels) ListPage(ctx context.Context, limit, page int) (Page[Label], error)

ListPage is List with the number of labels in the scope, as the server counts them.

func (Labels) RequireFilterNames

func (s Labels) RequireFilterNames(ctx context.Context, names []string) error

RequireFilterNames rejects names Gitea's repository issue filter cannot match: it matches repository labels by exact name and silently ignores every other name.

func (Labels) ResolveIssueNames

func (s Labels) ResolveIssueNames(ctx context.Context, names []string) ([]int64, error)

ResolveIssueNames resolves names through the repository's IssueCatalog.

func (Labels) Scope

func (s Labels) Scope() string

Scope names the repository or organization the labels belong to.

type ListOptions

type ListOptions struct {
	State                              string
	Limit, Page                        int
	Search                             string
	Assignee, Labels, Milestones, Kind string
	Author, Mentions                   string
	Since, Before                      *time.Time
	// NoAssignee keeps only issues without assignees. Gitea has no such filter, so ListPage
	// applies it to every issue it reads.
	NoAssignee bool
}

ListOptions supplies explicit issue pagination and filters.

type MemberListOptions

type MemberListOptions struct {
	// Public lists only public memberships, and Visibility reports the visibility of each one.
	// Gitea lists concealed members as public to administrators, so for them both check each
	// membership on its own, and Public drops the server's total, which counts concealed members
	// too.
	Public, Visibility bool
	Limit, Page        int
}

MemberListOptions selects a page of organization members.

type MergeOptions

type MergeOptions struct {
	Method, Title, Message string
	DeleteBranch, Auto     bool
	// HeadSHA is the head commit the user chose to merge; Gitea refuses the merge once the head
	// moved past it. Empty merges the current head.
	HeadSHA string
}

MergeOptions supplies merge strategy and optional commit text. Auto merges once the required checks succeed instead of now.

type MergeSettings

type MergeSettings struct {
	Styles       []string
	Default      string
	DeleteBranch bool
}

MergeSettings are the merge styles a repository allows, in Gitea's order, and its merge defaults.

type MetadataChanges

type MetadataChanges struct {
	AddLabels, RemoveLabels       []int64
	AddAssignees, RemoveAssignees []string
}

MetadataChanges adds and removes labels and assignees relative to an issue's current state.

type Milestone

type Milestone struct {
	ID           int64   `json:"id"`
	Title        string  `json:"title"`
	Description  string  `json:"description"`
	State        string  `json:"state"`
	Deadline     *string `json:"due_on"`
	OpenIssues   int     `json:"open_issues"`
	ClosedIssues int     `json:"closed_issues"`
}

Milestone is a stable milestone result.

type MilestoneOptions

type MilestoneOptions struct {
	Title       *string `json:"title,omitempty"`
	Description *string `json:"description,omitempty"`
	State       *string `json:"state,omitempty"`
	Deadline    *string `json:"due_on,omitempty"`
}

MilestoneOptions allows explicit state, description and deadline updates.

type Milestones

type Milestones struct {
	Client     *transport.Client
	Repository string
}

Milestones implements repository milestone operations.

func (Milestones) All

func (s Milestones) All(ctx context.Context) ([]Milestone, error)

All returns the open and closed milestones of the repository.

func (Milestones) AllIn

func (s Milestones) AllIn(ctx context.Context, state string) ([]Milestone, error)

AllIn returns every milestone in state: open, closed or all.

func (Milestones) Create

func (s Milestones) Create(ctx context.Context, opts MilestoneOptions) (Milestone, error)

Create creates one milestone.

func (Milestones) CreateUnique

func (s Milestones) CreateUnique(ctx context.Context, opts MilestoneOptions, update bool) (Milestone, bool, error)

CreateUnique creates a milestone unless one has its title, ignoring case, which titles would then no longer address. With update it edits that milestone instead and reports true.

func (Milestones) Delete

func (s Milestones) Delete(ctx context.Context, id int64) error

Delete deletes one milestone.

func (Milestones) Edit

func (s Milestones) Edit(ctx context.Context, id int64, opts MilestoneOptions) (Milestone, error)

Edit updates a milestone.

func (Milestones) EditUnique

func (s Milestones) EditUnique(ctx context.Context, existing []Milestone, current Milestone, opts MilestoneOptions) (Milestone, error)

EditUnique edits current like Edit but refuses to retitle it to the title of another milestone among existing, the milestones of the repository, ignoring case, which CreateUnique refuses too: titles would no longer address either milestone.

func (Milestones) FilterIDs

func (s Milestones) FilterIDs(ctx context.Context, values []string) ([]string, error)

FilterIDs resolves the milestones that filter an issue listing, each an ID or a title, to the values the issues API reads back as the same milestones: Gitea matches a filter value by title first and by ID only then, so a unique title without a comma is sent as is, and an ID only when no title reads like it. Gitea drops filter values that name no milestone and lists every issue when none is left, so an unknown milestone is an error here.

func (Milestones) FilterValue

func (s Milestones) FilterValue(ctx context.Context, item Milestone) (string, error)

FilterValue is the value that filters an issue listing by item, as FilterIDs resolves it.

func (Milestones) Find

func (s Milestones) Find(ctx context.Context, raws []string, byName bool) ([]Milestone, error)

Find returns the milestones that raws address among the open and closed milestones, each by ID or title; byName matches numeric values as titles only.

func (Milestones) FindIn

func (s Milestones) FindIn(items []Milestone, raw string, byName bool) (Milestone, error)

FindIn returns the milestone among items, the milestones of the repository, that raw addresses like Find.

func (Milestones) FindOne

func (s Milestones) FindOne(ctx context.Context, raw string, byName bool) (Milestone, error)

FindOne returns the milestone that raw addresses like Find.

func (Milestones) List

func (s Milestones) List(ctx context.Context, state string, limit, page int) ([]Milestone, error)

List returns a non-nil page of milestones.

type NameOrID

type NameOrID[T any] struct {
	// Kind and Scope name the resources in errors, such as "label" in "alice/project".
	Kind, Scope string
	ID          func(T) int64
	Name        func(T) string
	// ByName matches numeric values as names only, for --by-name.
	ByName bool
	// Exact matches names case-sensitively only, for resources such as release assets whose
	// names may differ only in case.
	Exact bool
	// NoIDs marks resources that commands only name by title, such as projects.
	NoIDs bool
}

NameOrID addresses one kind of resource by name or ID: a numeric value is an ID first, then a name; any other value is an exact name, then a unique case-insensitive name unless Exact is set.

func (NameOrID[T]) Find

func (n NameOrID[T]) Find(items []T, raw string) (T, error)

Find returns the item among items that raw addresses. It fails with a *NotFoundError when nothing matches and an *AmbiguousError listing the IDs when several names match.

type NotFoundError

type NotFoundError struct {
	// Kind names the resource, such as "issue" or "label".
	Kind string
	// Key identifies the resource as the user wrote it, such as "#999", "v1.0" or `"bug"`.
	Key string
	// Scope is the repository or organization that was searched; empty for instance-wide resources.
	Scope string
	// Err is the underlying failure, usually a 404 *transport.APIError.
	Err error
}

NotFoundError reports a missing resource by the name the user gave it, such as "issue #999 not found in alice/project".

func NotFound

func NotFound(kind, key, scope string) *NotFoundError

NotFound reports that no kind named key exists in scope.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

func (*NotFoundError) Unwrap

func (e *NotFoundError) Unwrap() error

type NotInMilestoneError

type NotInMilestoneError struct {
	Number    int64
	Milestone string
}

NotInMilestoneError reports an issue that RemoveMilestone left unchanged, as it is not in the milestone.

func (*NotInMilestoneError) Error

func (e *NotInMilestoneError) Error() string

type NotPlainCommentError

type NotPlainCommentError struct {
	ID         int64
	Repository string
}

NotPlainCommentError reports a comment that the single-comment endpoint answers with no body, such as an inline review comment. Such comments can still be edited and deleted by ID.

func (NotPlainCommentError) Error

func (e NotPlainCommentError) Error() string

type NotPullError

type NotPullError struct {
	Number     int64
	Repository string
	// Err is the *NotFoundError of the pull request.
	Err error
}

NotPullError reports that the number a pull request was asked for is an issue's.

func (*NotPullError) Error

func (e *NotPullError) Error() string

func (*NotPullError) Unwrap

func (e *NotPullError) Unwrap() error

type Notification

type Notification struct {
	ID         int64  `json:"id"`
	Repository string `json:"repository"`
	// Number is the issue or pull request number of the subject, when it is one.
	Number    int64  `json:"number,omitempty"`
	Title     string `json:"title"`
	URL       string `json:"url"`
	Type      string `json:"type"`
	State     string `json:"state"`
	Unread    bool   `json:"unread"`
	Pinned    bool   `json:"pinned"`
	UpdatedAt string `json:"updated_at"`
	// contains filtered or unexported fields
}

Notification is the stable representation of an account notification thread.

type NotificationOptions

type NotificationOptions struct {
	Limit, Page     int
	Statuses, Types []string
	Since, Before   *time.Time
}

NotificationOptions supplies pagination and server-supported filters.

type Notifications

type Notifications struct {
	Client     *transport.Client
	Repository string
}

Notifications manages account threads, optionally scoped to one repository.

func (Notifications) LatestComment

func (s Notifications) LatestComment(ctx context.Context, item Notification) (*Comment, error)

LatestComment returns the latest comment on the subject of a notification, or nil without one.

func (Notifications) List

List returns a non-nil page of notifications and what the server reported about the rest.

func (Notifications) Mark

func (s Notifications) Mark(ctx context.Context, id int64, status string) (Notification, error)

Mark changes the selected notification status.

func (Notifications) MarkAll

func (s Notifications) MarkAll(ctx context.Context, status string, filters []string, before time.Time) ([]Notification, error)

MarkAll applies a status to all matching notifications within the selected scope.

func (Notifications) View

func (s Notifications) View(ctx context.Context, id int64) (Notification, error)

View retrieves an account-owned notification thread.

func (Notifications) Watch

func (s Notifications) Watch(ctx context.Context, opts NotificationOptions, interval time.Duration, onChange func([]Notification) error) error

Watch reports new or changed threads and propagates cancellation and callback errors. It polls on through an outage of the instance of up to pollOutage once a poll succeeded. The first poll reports the page opts selects; later polls read on past it while every thread on a page is new, so a burst of more than a page of notifications between two polls is reported whole.

type Organization

type Organization struct {
	ID                        int64  `json:"id"`
	Name                      string `json:"name"`
	FullName                  string `json:"full_name"`
	Description               string `json:"description"`
	Website                   string `json:"website"`
	Location                  string `json:"location"`
	Visibility                string `json:"visibility"`
	RepoAdminChangeTeamAccess bool   `json:"repo_admin_change_team_access"`
}

Organization is the public command representation of a Gitea organization.

type OrganizationMember

type OrganizationMember struct {
	ID       int64  `json:"id"`
	Username string `json:"username"`
	FullName string `json:"full_name"`
	// Visibility of an organization membership is public or concealed; team members have none.
	Visibility string `json:"visibility,omitempty"`
}

OrganizationMember identifies a member without exposing private profile fields.

type OrganizationOptions

type OrganizationOptions struct {
	Name                      *string `json:"username,omitempty"`
	FullName                  *string `json:"full_name,omitempty"`
	Description               *string `json:"description,omitempty"`
	Website                   *string `json:"website,omitempty"`
	Location                  *string `json:"location,omitempty"`
	Visibility                *string `json:"visibility,omitempty"`
	RepoAdminChangeTeamAccess *bool   `json:"repo_admin_change_team_access,omitempty"`
}

OrganizationOptions permits explicit empty and false preference updates.

type OrganizationSize

type OrganizationSize struct {
	Members, Teams, Repositories *int
}

OrganizationSize counts what an organization holds; a count the account cannot read is nil.

type Organizations

type Organizations struct{ Client *transport.Client }

Organizations implements instance-scoped organization workflows.

func (Organizations) CanGrantTeamAccess

func (s Organizations) CanGrantTeamAccess(ctx context.Context, org string, team int64) (bool, error)

CanGrantTeamAccess reports whether the account may grant team of org access to a repository it creates. Gitea allows site administrators and owners of org, and members of the team when org lets repository administrators change team access.

func (Organizations) Create

Create creates an organization owned by the selected account.

func (Organizations) Delete

func (s Organizations) Delete(ctx context.Context, name string) error

Delete deletes the named organization.

func (Organizations) Edit

Edit changes only supplied organization preferences.

func (Organizations) IsMember

func (s Organizations) IsMember(ctx context.Context, name, username string) (bool, error)

IsMember reports whether username belongs to the organization. It fails with a *NotFoundError when the organization or the user does not exist.

func (Organizations) IsPublicMember

func (s Organizations) IsPublicMember(ctx context.Context, name, username string) (bool, error)

IsPublicMember reports whether username's membership of the organization is public.

func (Organizations) List

func (s Organizations) List(ctx context.Context, mine bool, username string, limit, page int) (Page[Organization], error)

List selects public organizations, your organizations, or a named user's organizations.

func (Organizations) Members

Members lists the members of an organization.

func (Organizations) RemoveMember

func (s Organizations) RemoveMember(ctx context.Context, name, username string) error

RemoveMember removes an organization member and their organization access.

func (Organizations) RepositoryCount

func (s Organizations) RepositoryCount(ctx context.Context, name string) (*int, error)

RepositoryCount counts the repositories of an organization, or returns nil when the account cannot read the count.

func (Organizations) SetMemberPublic

func (s Organizations) SetMemberPublic(ctx context.Context, name, username string, public bool) error

SetMemberPublic changes public visibility of an existing membership.

func (Organizations) Size

Size counts the members, teams and repositories of an organization; a count the account cannot read is nil.

func (Organizations) View

func (s Organizations) View(ctx context.Context, name string) (Organization, error)

View retrieves a named organization.

type Package

type Package struct {
	ID         int64  `json:"id"`
	Owner      string `json:"owner"`
	Type       string `json:"type"`
	Name       string `json:"name"`
	Version    string `json:"version"`
	Repository string `json:"repository"`
	Creator    string `json:"creator"`
	URL        string `json:"url"`
	CreatedAt  string `json:"created_at"`
}

Package is one version of a package in an owner's package registry.

type PackageFile

type PackageFile struct {
	ID     int64  `json:"id"`
	Name   string `json:"name"`
	Size   int64  `json:"size"`
	SHA256 string `json:"sha256"`
}

PackageFile is one file of a package version.

type PackageListOptions

type PackageListOptions struct {
	Type, Query string
	Limit, Page int
}

PackageListOptions selects packages by type and name.

type Packages

type Packages struct {
	Client *transport.Client
	Owner  string
}

Packages manages the package registry of a user or organization.

func (Packages) CheckGenericUpload

func (s Packages) CheckGenericUpload(ctx context.Context, name, version string, files []string) error

CheckGenericUpload refuses to upload files to a version of a generic package that holds a file of the same name already, ignoring case as Gitea does; a new version holds none.

func (Packages) Delete

func (s Packages) Delete(ctx context.Context, kind, name, version string) error

Delete deletes one version of a package, or every version when version is empty.

func (Packages) Files

func (s Packages) Files(ctx context.Context, kind, name, version string) ([]PackageFile, error)

Files lists the files of one package version.

func (s Packages) Link(ctx context.Context, kind, name, repository string) error

Link links a package to a repository of its owner, or with repository empty unlinks it.

func (Packages) List

List returns a page of the owner's packages, one entry per version.

func (Packages) UploadGeneric

func (s Packages) UploadGeneric(ctx context.Context, name, version, file string, input io.Reader) error

UploadGeneric streams one file into a version of a generic package, creating either as needed. TODO(sdk): the SDK has no client for the package registries' upload endpoints.

func (Packages) Versions

func (s Packages) Versions(ctx context.Context, kind, name string, limit, page int) (Page[Package], error)

Versions returns a page of the versions of one package.

func (Packages) View

func (s Packages) View(ctx context.Context, kind, name, version string) (Package, error)

View returns one version of a package, or its latest version when version is empty.

type Page

type Page[T any] struct {
	Items []T
	// More reports whether the collection continues past Items.
	More bool
	// Total is the size of the whole collection when Counted, from X-Total-Count.
	Total   int
	Counted bool
}

Page is one window of a collection and what the server reported about the rest of it.

func PageOf

func PageOf[T any](items []T, limit, page int) (Page[T], error)

PageOf returns one CLI page of a complete collection, counting the whole collection.

type PartialEditError

type PartialEditError struct {
	Saved, Failed []string
	Errs          []error
	Number        int64
	ReadErr       error
}

PartialEditError reports an edit that Gitea took only in part: the changes that Saved names were saved, and those that Failed names were not. Errs are the errors of the requests that failed; one that names its change, as that of a request which sent only it, keeps the change out of Failed. ReadErr is set when pull request Number could not be read back after the failure: the changes besides Saved and Failed may or may not have been saved then.

func (*PartialEditError) Error

func (e *PartialEditError) Error() string

func (*PartialEditError) Unwrap

func (e *PartialEditError) Unwrap() []error

type Projects

type Projects struct {
	Client     *transport.Client
	Repository string
}

Projects places the issues and pull requests of a repository on its project boards, or on those of the organization that owns it.

func (Projects) Add

func (s Projects) Add(ctx context.Context, board *Board, issueID int64) (bool, error)

Add puts the issue with the global ID issueID in the default column of board, and reports whether it sent the request: an issue already on the board keeps its column. A board without columns first gets the default column Gitea creates for it on the web.

func (Projects) Boards

func (s Projects) Boards(ctx context.Context, titles []string, withIssues bool) ([]Board, error)

Boards resolves the open projects titled titles, a title's case mattering only to tell two projects apart: the repository's, else its organization's. It loads each board once, however many issues are then put on it or taken off; withIssues also reads which issues each holds, which issues that are not new need.

func (Projects) Remove

func (s Projects) Remove(ctx context.Context, board Board, issueID int64) (bool, error)

Remove takes the issue with the global ID issueID off board, and reports whether it sent the request: an issue that is not on it is left as it is.

type Protection

type Protection struct {
	// Rule is the branch name, or a glob pattern such as release/*, that the rule protects.
	Rule              string `json:"rule"`
	RequiredApprovals int64  `json:"required_approvals"`
	// PushUsers and PushTeams may push directly; without them nobody can.
	PushUsers []string `json:"push_users"`
	PushTeams []string `json:"push_teams"`
	// StatusChecks must pass before pull requests merge.
	StatusChecks          []string `json:"status_checks"`
	BlockOnRejected       bool     `json:"block_on_rejected_reviews"`
	DismissStaleApprovals bool     `json:"dismiss_stale_approvals"`
}

Protection is a branch protection rule.

type ProtectionChanges

type ProtectionChanges struct {
	RequiredApprovals, Pushers, StatusChecks, BlockOnRejected, DismissStaleApprovals bool
}

ProtectionChanges selects the settings of a Protection that EditProtection changes.

type Pull

type Pull struct {
	Author    string          `json:"author"`
	CreatedAt string          `json:"created_at"`
	UpdatedAt string          `json:"updated_at"`
	Assignees []string        `json:"assignees"`
	Milestone *IssueMilestone `json:"milestone"`
	Labels    []Label         `json:"labels"`
	Deadline  *string         `json:"due_date"`
	ID        int64           `json:"id"`
	Number    int64           `json:"number"`
	Title     string          `json:"title"`
	Body      string          `json:"body"`
	URL       string          `json:"url"`
	State     string          `json:"state"`
	Merged    bool            `json:"merged"`
	MergedAt  *string         `json:"merged_at"`
	// MergedBy is only in responses for one pull request; lists leave it out.
	MergedBy string `json:"merged_by"`
	// MergeCommitSHA is the commit the merge created on the base branch, or null.
	MergeCommitSHA *string `json:"merge_commit_sha"`
	Mergeable      bool    `json:"mergeable"`
	Draft          bool    `json:"draft"`
	// ReviewDecision summarizes the reviews like gh: approved, changes_requested, review_required
	// or "". Only commands that read the reviews fill it.
	ReviewDecision    string `json:"review_decision"`
	Base              string `json:"base"`
	Head              string `json:"head"`
	HeadSHA           string `json:"head_sha"`
	HeadRepo          string `json:"head_repo"`
	HeadRemoteDeleted bool   `json:"head_remote_deleted"`
	HeadCanPush       bool   `json:"-"`
	HeadCloneURL      string `json:"-"`
	HeadSSHURL        string `json:"-"`
	// AllowMaintainerEdit tells whether maintainers can push to the head branch.
	AllowMaintainerEdit bool `json:"-"`
	// Reviewers and ReviewerTeams are the outstanding review requests. Gitea's own list also
	// names users who already reviewed, so commands that read the reviews replace them with
	// WithReviews.
	Reviewers     []string `json:"reviewers"`
	ReviewerTeams []string `json:"reviewer_teams"`
	// Reviews are the submitted reviews, oldest first, filled by WithReviews and otherwise empty.
	Reviews  []Review `json:"reviews"`
	Comments int64    `json:"comments"`
}

Pull is the stable command representation of a pull request.

type PullCreateChoices

type PullCreateChoices struct {
	Repository Repository
	Base       PullRepository
	Template   string
	CreateSelectables
}

PullCreateChoices seed the interactive create form: the repository, its pull request template on the default branch, and the metadata selectables.

type PullEdit

type PullEdit struct {
	Labels              *[]int64              `json:"-"`
	Title               *string               `json:"title,omitempty"`
	Body                *string               `json:"body,omitempty"`
	State               *string               `json:"state,omitempty"`
	Base                *string               `json:"base,omitempty"`
	AllowMaintainerEdit *bool                 `json:"allow_maintainer_edit,omitempty"`
	Assignees           *[]string             `json:"assignees,omitempty"`
	Milestone           *int64                `json:"-"`
	ReviewerChanges     *ReviewRequestChanges `json:"-"`
	Deadline            *time.Time            `json:"due_date,omitempty"`
	RemoveDeadline      *bool                 `json:"unset_due_date,omitempty"`
	Changes             *MetadataChanges      `json:"-"`
}

PullEdit distinguishes omitted fields from explicit empty values.

type PullListOptions

type PullListOptions struct {
	State, Sort, Author, Base string
	Limit, Page               int
	Milestone                 int64
	Labels                    []int64
	// Draft, Head (BRANCH or OWNER:BRANCH), Assignee, NoAssignee, Search (text in the title or
	// body) and the merged state have no server filter; List applies them to every pull request
	// it reads.
	Draft, NoAssignee      bool
	Head, Assignee, Search string
}

PullListOptions filters pull requests. State is open, closed, merged or all.

type PullOptions

type PullOptions struct {
	Assignees           []string   `json:"assignees,omitempty"`
	Labels              []int64    `json:"labels,omitempty"`
	Milestone           int64      `json:"milestone,omitempty"`
	Deadline            *time.Time `json:"due_date,omitempty"`
	Title               string     `json:"title"`
	Body                string     `json:"body"`
	Base                string     `json:"base"`
	Head                string     `json:"head"`
	AllowMaintainerEdit *bool      `json:"allow_maintainer_edit,omitempty"`
}

PullOptions supplies validated branch and content input for creation.

type PullRepository

type PullRepository struct {
	Repository    string
	DefaultBranch string
	PullsEnabled  bool
	// CanPush is whether the account may push branches to it. A response without permissions, as
	// for an anonymous request, leaves it to the push.
	CanPush bool
}

PullRepository is what creating a pull request needs to know about the repository it goes into.

func (PullRepository) CheckEnabled

func (r PullRepository) CheckEnabled() error

CheckEnabled returns the UnitError of a repository with its pull requests turned off, so that a command can refuse before it prompts or pushes a branch.

type PullStatus

type PullStatus struct {
	CurrentBranch   *Pull        `json:"current_branch"`
	Authored        []SearchItem `json:"authored"`
	Assigned        []SearchItem `json:"assigned"`
	ReviewRequested []SearchItem `json:"review_requested"`
}

PullStatus groups open pull requests by the selected account's participation. CurrentBranch is the pull request of the checked-out branch, which commands fill when they know it.

type Pulls

type Pulls struct {
	Client     *transport.Client
	Repository string
}

Pulls implements repository pull request operations.

func (Pulls) Base

func (s Pulls) Base(ctx context.Context) (PullRepository, error)

Base reads the repository of the pull requests, for a new one.

func (Pulls) CheckUsers

func (s Pulls) CheckUsers(ctx context.Context, assignees, reviewers []string) error

CheckUsers verifies that the named assignees and reviewers, such as those of a pull request about to be created, exist, so that an unknown name fails before a branch is pushed or the pull request exists. A user the account may not see is left for Gitea to refuse, and so is a reviewer named by email address, which Gitea looks up by email; assignees are taken by name only.

func (Pulls) Checks

func (s Pulls) Checks(ctx context.Context, n int64) ([]Check, error)

Checks returns latest contexts for the PR head in its base repository, as Gitea does.

func (Pulls) CommitChecks

func (s Pulls) CommitChecks(ctx context.Context, sha string) ([]Check, error)

CommitChecks returns the latest status of each check context of a commit.

func (Pulls) Create

func (s Pulls) Create(ctx context.Context, opts PullOptions) (Pull, error)

Create opens a pull request.

func (Pulls) CreateChoices

func (s Pulls) CreateChoices(ctx context.Context) (PullCreateChoices, error)

CreateChoices fetches the repository once for its default branch and permissions, refusing one with its pull requests turned off, then loads the pull request template and the selectables concurrently.

func (Pulls) DeleteHead

func (s Pulls) DeleteHead(ctx context.Context, item Pull) error

DeleteHead deletes the head branch of a pull request in its head repository.

func (Pulls) Detail

func (s Pulls) Detail(ctx context.Context, items []Pull, view, reviews bool) ([]Pull, error)

Detail reads, a few pull requests at a time, what a listing leaves out: with view, each pull request again, for merged_by; with reviews, its reviews, for WithReviews.

func (Pulls) Diff

func (s Pulls) Diff(ctx context.Context, n int64) (io.ReadCloser, error)

Diff returns the pull request's patch, which the caller must close.

func (Pulls) Edit

func (s Pulls) Edit(ctx context.Context, n int64, opts PullEdit) (Pull, error)

Edit updates only explicitly supplied resource fields.

func (Pulls) EditFrom

func (s Pulls) EditFrom(ctx context.Context, n int64, opts PullEdit, before *Pull) (Pull, error)

EditFrom is Edit for pull request n as before holds it just ahead of the edit, or nil when it was not read. When an edit of several fields fails, the pull request read back is compared with before to tell what was saved; without before, such an edit reads it first.

func (Pulls) Files

func (s Pulls) Files(ctx context.Context, n int64) ([]string, error)

Files lists the paths of the files a pull request changes.

func (Pulls) List

func (s Pulls) List(ctx context.Context, options PullListOptions) ([]Pull, bool, error)

List returns a page of pull requests, even when the server caps its page size below the limit, and reports whether more pull requests follow.

func (Pulls) ListOpen

func (s Pulls) ListOpen(ctx context.Context) ([]Pull, error)

ListOpen returns every open pull request in the repository.

func (Pulls) ListPage

func (s Pulls) ListPage(ctx context.Context, options PullListOptions) (Page[Pull], error)

ListPage is List that also reports how many pull requests match, when the server counts them or every pull request was read for a filter without a server equivalent. Such a filter reads pages only until one pull request past the requested page matches.

func (Pulls) Merge

func (s Pulls) Merge(ctx context.Context, n int64, opts MergeOptions) error

Merge merges the pull request's head opts.HeadSHA, else its current head, with the selected strategy. When Gitea refuses the merge, the error names the reason derived from the pull request, since Gitea reports conflicts only as "try again later". Gitea answers the same while it checks the pull request again after its base branch moved, so such a refusal of an open pull request is retried once after a short delay.

func (Pulls) MergeSettings

func (s Pulls) MergeSettings(ctx context.Context) (MergeSettings, error)

MergeSettings reads the merge styles the repository allows and its default style and branch deletion. A default style that is not allowed falls back to the first allowed one.

func (Pulls) NewestClosed

func (s Pulls) NewestClosed(ctx context.Context, keep func(Pull) bool) (Pull, bool, error)

NewestClosed returns the most recently updated closed or merged pull request that keep accepts, and whether there is one. It reads pages newest first and stops at the first match.

func (Pulls) PushableFork

func (s Pulls) PushableFork(ctx context.Context, repo string) (bool, error)

PushableFork reports whether repo is a fork of the pull requests' repository that the account may push to, so that it can hold the head branch of a new pull request.

func (Pulls) Template

func (s Pulls) Template(ctx context.Context, ref string) (string, error)

Template returns the first pull request template found at ref, or "" when the repository has none. All paths are probed concurrently; the result is decided in priority order, so a failure is reported only when every higher-priority path is missing.

func (Pulls) View

func (s Pulls) View(ctx context.Context, n int64) (Pull, error)

View retrieves one pull request.

func (Pulls) WatchChecks

func (s Pulls) WatchChecks(ctx context.Context, n int64, interval time.Duration, changed func([]Check) error) ([]Check, error)

WatchChecks follows the current PR head until contexts finish or a check fails. An empty status set waits for checks to be registered instead of claiming success.

func (Pulls) WithReviews

func (s Pulls) WithReviews(ctx context.Context, p Pull, reviews []Review) Pull

WithReviews returns p with its reviewers, reviewer teams, reviews and review decision taken from reviews, all of its reviews. While the protection of the base branch requires approvals, the decision is approved only with as many official ones as Gitea counts for merging, and review_required with fewer.

type RefusedError

type RefusedError struct {
	Text string
	// Err is the underlying *transport.APIError.
	Err error
}

RefusedError words a refusal that Gitea answers without naming what it refused, such as a 403 "write permission is required".

func (*RefusedError) Error

func (e *RefusedError) Error() string

func (*RefusedError) Unwrap

func (e *RefusedError) Unwrap() error

type Release

type Release struct {
	ID          int64          `json:"id"`
	Tag         string         `json:"tag"`
	Target      string         `json:"target"`
	Title       string         `json:"title"`
	Body        string         `json:"body"`
	URL         string         `json:"url"`
	Draft       bool           `json:"draft"`
	Prerelease  bool           `json:"prerelease"`
	Author      string         `json:"author"`
	Assets      []ReleaseAsset `json:"assets"`
	CreatedAt   string         `json:"created_at"`
	PublishedAt *string        `json:"published_at"`
}

Release describes a repository release.

type ReleaseAsset

type ReleaseAsset struct {
	ID            int64  `json:"id"`
	Name          string `json:"name"`
	Size          int64  `json:"size"`
	URL           string `json:"url"`
	CreatedAt     string `json:"created_at"`
	DownloadCount int64  `json:"download_count"`
}

ReleaseAsset is the public metadata of a release attachment.

type ReleaseOptions

type ReleaseOptions struct {
	Tag        *string `json:"tag_name,omitempty"`
	Target     *string `json:"target_commitish,omitempty"`
	Title      *string `json:"name,omitempty"`
	Body       *string `json:"body,omitempty"`
	Draft      *bool   `json:"draft,omitempty"`
	Prerelease *bool   `json:"prerelease,omitempty"`
}

ReleaseOptions distinguishes omitted fields from explicit empty or false values.

type Releases

type Releases struct {
	Client     *transport.Client
	Repository string
}

Releases implements repository release workflows.

func (Releases) Archive

func (s Releases) Archive(ctx context.Context, ref, format string) (io.ReadCloser, error)

Archive opens the source archive of the repository at ref; format is zip or tar.gz. TODO(sdk): GetArchiveReader cannot follow the redirect to object storage that serves archives directly.

func (Releases) Create

func (s Releases) Create(ctx context.Context, opts ReleaseOptions) (Release, error)

Create creates a release and lets Gitea create a missing tag at the supplied target.

func (Releases) Delete

func (s Releases) Delete(ctx context.Context, item Release, deleteTag bool) error

Delete removes a release and optionally its tag; partial failures identify the completed step.

func (Releases) DeleteAsset

func (s Releases) DeleteAsset(ctx context.Context, id, asset int64) error

DeleteAsset removes one asset from the selected release.

func (Releases) DownloadAsset

func (s Releases) DownloadAsset(ctx context.Context, id, asset int64) (io.ReadCloser, error)

DownloadAsset opens a repository-validated attachment stream at its direct instance URL.

func (Releases) Edit

func (s Releases) Edit(ctx context.Context, id int64, opts ReleaseOptions) (Release, error)

Edit changes only supplied release fields; Gitea ignores empty text fields.

func (Releases) Latest

func (s Releases) Latest(ctx context.Context) (Release, error)

Latest retrieves the most recent release that is neither a draft nor a prerelease.

func (Releases) ListPage

func (s Releases) ListPage(ctx context.Context, limit, page int) (Page[Release], error)

ListPage lists a page of releases, with whether more follow and how many there are.

func (Releases) RenameAsset

func (s Releases) RenameAsset(ctx context.Context, id, asset int64, name string) (ReleaseAsset, error)

RenameAsset changes only an attachment's display name.

func (Releases) TagExists

func (s Releases) TagExists(ctx context.Context, tag string) (bool, error)

TagExists reports whether the repository on the server has the tag.

func (Releases) UploadAsset

func (s Releases) UploadAsset(ctx context.Context, id int64, name string, input io.Reader) (ReleaseAsset, error)

UploadAsset streams a multipart upload without buffering the asset in memory.

func (Releases) View

func (s Releases) View(ctx context.Context, tag string) (Release, error)

View retrieves a release by its tag, including numeric tags.

type Repositories

type Repositories struct{ Client *transport.Client }

Repositories implements Gitea repository operations.

func (Repositories) Assignees

func (s Repositories) Assignees(ctx context.Context, repo string) ([]Assignee, error)

Assignees lists the users that can be assigned on repository issues.

func (Repositories) Create

func (s Repositories) Create(ctx context.Context, org string, opts RepositoryOptions) (Repository, error)

Create creates a repository for the account or the named organization.

func (Repositories) Delete

func (s Repositories) Delete(ctx context.Context, repo string) error

Delete removes the selected repository.

func (Repositories) Edit

func (s Repositories) Edit(ctx context.Context, repo string, opts RepositoryEdit) (Repository, error)

Edit updates only explicitly supplied resource fields.

func (Repositories) Fork

func (s Repositories) Fork(ctx context.Context, repo string, opts ForkOptions) (Repository, bool, error)

Fork forks repo for the account or the organization. When that owner already has a fork of repo, Fork returns it and reports that it existed.

func (Repositories) Generate

func (s Repositories) Generate(ctx context.Context, source string, opts RepositoryTemplateOptions) (Repository, error)

Generate creates a repository from a template on the selected instance.

func (Repositories) Gitignores

func (s Repositories) Gitignores(ctx context.Context) ([]string, error)

Gitignores lists the .gitignore templates that repository creation accepts.

func (Repositories) LabelTemplates

func (s Repositories) LabelTemplates(ctx context.Context) ([]string, error)

LabelTemplates lists the label sets that repository creation accepts.

func (Repositories) Licenses

func (s Repositories) Licenses(ctx context.Context) ([]string, error)

Licenses lists the license templates that repository creation accepts.

func (Repositories) List

List returns repositories accessible to the account, or its selected collection. It reports whether more repositories follow the selected page.

func (Repositories) ListPage

ListPage is List that also reports the size of the collection when the server counts it. The server has no kind filter, so a kind is filtered on the client, reading pages until the requested one is full.

func (Repositories) MergeUpstream

func (s Repositories) MergeUpstream(ctx context.Context, repo, branch string) (string, error)

MergeUpstream fast-forwards branch of the fork repo to its parent's branch on the server. It returns how Gitea updated the branch: "fast-forward", or "up-to-date" when there was nothing to do.

func (Repositories) Migrate

Migrate imports a remote repository through Gitea's migration API.

func (Repositories) MirrorSync

func (s Repositories) MirrorSync(ctx context.Context, repo string) error

MirrorSync asks the server to update the pull mirror repo from its source; the update runs in the background.

func (Repositories) Readme

func (s Repositories) Readme(ctx context.Context, repo, ref string) (path, content string, err error)

Readme returns the README of the repository at ref as Gitea's web view finds it, searching .gitea, .github, the root and docs: its path and its content, or "" when there is none. An explicit ref that does not exist is an error.

func (Repositories) Search

Search searches repository names, descriptions or topics within one instance.

func (Repositories) SetTopics

func (s Repositories) SetTopics(ctx context.Context, repo string, topics []string) error

SetTopics replaces the topics of the repository.

func (Repositories) Tags

func (s Repositories) Tags(ctx context.Context, repo string, limit, page int) ([]string, error)

Tags lists a page of the repository's tag names.

func (Repositories) Topics

func (s Repositories) Topics(ctx context.Context, repo string) ([]string, error)

Topics lists the topics of the repository. Gitea allows at most 25, so one page holds them all.

func (Repositories) Transfer

func (s Repositories) Transfer(ctx context.Context, repo, newOwner string, teams []int64) (RepositoryTransfer, error)

Transfer moves repo to newOwner and grants the teams of an organization access to it. Gitea makes the transfer wait for the new owner when the account may not create repositories there.

func (Repositories) View

func (s Repositories) View(ctx context.Context, repo string) (Repository, error)

View retrieves one repository.

type Repository

type Repository struct {
	ActionsEnabled bool        `json:"actions_enabled"`
	Website        string      `json:"website"`
	ID             int64       `json:"id"`
	Name           string      `json:"name"`
	FullName       string      `json:"full_name"`
	Description    string      `json:"description"`
	URL            string      `json:"url"`
	Private        bool        `json:"private"`
	DefaultBranch  string      `json:"default_branch"`
	CloneURL       string      `json:"clone_url"`
	SSHURL         string      `json:"ssh_url"`
	Archived       bool        `json:"archived"`
	Template       bool        `json:"template"`
	Fork           bool        `json:"fork"`
	Mirror         bool        `json:"mirror"`
	Empty          bool        `json:"empty"`
	Stars          int         `json:"stars_count"`
	Forks          int         `json:"forks_count"`
	OpenIssues     int         `json:"open_issues_count"`
	OpenPulls      int         `json:"open_pr_count"`
	Topics         []string    `json:"topics"`
	UpdatedAt      string      `json:"updated_at"`
	Parent         *Repository `json:"parent"`
	// OriginalURL stays out of JSON output: migration sources may embed credentials.
	OriginalURL string `json:"-"`
	// Source is OriginalURL without credentials.
	Source         string `json:"original_url"`
	MirrorInterval string `json:"mirror_interval"`
}

Repository is the stable command representation of a repository.

type RepositoryEdit

type RepositoryEdit struct {
	ActionsEnabled *bool   `json:"has_actions,omitempty"`
	Name           *string `json:"name,omitempty"`
	Website        *string `json:"website,omitempty"`
	DefaultBranch  *string `json:"default_branch,omitempty"`
	Description    *string `json:"description,omitempty"`
	Private        *bool   `json:"private,omitempty"`
	Archived       *bool   `json:"archived,omitempty"`
	Template       *bool   `json:"template,omitempty"`
	Issues         *bool   `json:"has_issues,omitempty"`
	Wiki           *bool   `json:"has_wiki,omitempty"`
	PullRequests   *bool   `json:"has_pull_requests,omitempty"`
	Projects       *bool   `json:"has_projects,omitempty"`
	MergeCommits   *bool   `json:"allow_merge_commits,omitempty"`
	Squash         *bool   `json:"allow_squash_merge,omitempty"`
	Rebase         *bool   `json:"allow_rebase,omitempty"`
	MergeStyle     *string `json:"default_merge_style,omitempty"`
	DeleteBranch   *bool   `json:"default_delete_branch_after_merge,omitempty"`
}

RepositoryEdit distinguishes omitted settings from explicit false values.

type RepositoryListOptions

type RepositoryListOptions struct {
	Owner, Kind      string
	Starred, Watched bool
	Limit, Page      int
}

RepositoryListOptions selects a repository collection and page.

type RepositoryMigrationOptions

type RepositoryMigrationOptions struct {
	Name           string        `json:"repo_name"`
	Owner          string        `json:"repo_owner,omitempty"`
	CloneURL       string        `json:"clone_addr"`
	Service        string        `json:"service"`
	AuthUser       string        `json:"auth_username,omitempty"`
	AuthPassword   string        `json:"auth_password,omitempty"`
	AuthToken      string        `json:"auth_token,omitempty"`
	Mirror         bool          `json:"mirror"`
	Private        bool          `json:"private"`
	Description    string        `json:"description,omitempty"`
	Wiki           bool          `json:"wiki"`
	Milestones     bool          `json:"milestones"`
	Labels         bool          `json:"labels"`
	Issues         bool          `json:"issues"`
	PullRequests   bool          `json:"pull_requests"`
	Releases       bool          `json:"releases"`
	MirrorInterval string        `json:"mirror_interval,omitempty"`
	LFS            bool          `json:"lfs"`
	LFSEndpoint    string        `json:"lfs_endpoint,omitempty"`
	Timeout        time.Duration `json:"-"`
}

RepositoryMigrationOptions is explicit server-side import input. Credentials stay in request bodies.

type RepositoryOptions

type RepositoryOptions struct {
	Name          string `json:"name"`
	Description   string `json:"description,omitempty"`
	Private       bool   `json:"private"`
	AutoInit      bool   `json:"auto_init"`
	DefaultBranch string `json:"default_branch,omitempty"`
	Labels        string `json:"issue_labels,omitempty"`
	Gitignores    string `json:"gitignores,omitempty"`
	License       string `json:"license,omitempty"`
	Readme        string `json:"readme,omitempty"`
	Template      bool   `json:"template"`
	TrustModel    string `json:"trust_model,omitempty"`
	ObjectFormat  string `json:"object_format_name,omitempty"`
}

RepositoryOptions supplies repository creation input.

type RepositoryPermissions

type RepositoryPermissions struct {
	Admin bool `json:"admin"`
	Push  bool `json:"push"`
	Pull  bool `json:"pull"`
}

RepositoryPermissions holds server-side access flags used only for local decisions. It is intentionally omitted from the stable Repository JSON schema.

type RepositorySearchOptions

type RepositorySearchOptions struct {
	Query, Owner, Kind, Sort, Order string
	Topic                           bool
	Private, Archived               *bool
	Limit, Page                     int
}

RepositorySearchOptions supplies explicit repository search filters.

type RepositoryTemplateOptions

type RepositoryTemplateOptions struct {
	Name          string `json:"name"`
	Owner         string `json:"owner"`
	Description   string `json:"description"`
	DefaultBranch string `json:"default_branch,omitempty"`
	Private       bool   `json:"private"`
	Content       bool   `json:"git_content"`
	GitHooks      bool   `json:"git_hooks"`
	Avatar        bool   `json:"avatar"`
	Labels        bool   `json:"labels"`
	Topics        bool   `json:"topics"`
	Webhooks      bool   `json:"webhooks"`
}

RepositoryTemplateOptions controls copying from a template repository.

type RepositoryTransfer

type RepositoryTransfer struct {
	Repository
	Pending bool `json:"transfer_pending"`
}

RepositoryTransfer is a repository whose transfer was requested. A pending transfer waits for the new owner to accept it, and the repository keeps its owner until then.

type Review

type Review struct {
	ID            int64  `json:"id"`
	Body          string `json:"body"`
	State         string `json:"state"`
	Author        string `json:"author"`
	Team          string `json:"team"`
	URL           string `json:"url"`
	Commit        string `json:"commit"`
	SubmittedAt   string `json:"submitted_at"`
	CommentsCount int    `json:"comments_count"`
	Dismissed     bool   `json:"dismissed"`
	// Stale tells whether the pull request changed since the review.
	Stale bool `json:"stale"`
	// Official tells whether the review counts towards the approvals the base branch requires.
	Official bool `json:"official"`
}

Review is a stable review result.

func LatestReviews

func LatestReviews(reviews []Review) []Review

LatestReviews returns each reviewer's latest review, in the order of their first review. Pending reviews, which only their author sees, are left out; a later request for a review replaces a review.

func (Review) Reviewer

func (r Review) Reviewer() string

Reviewer names who the review is by, or for a request to a team, "team NAME".

type ReviewComment

type ReviewComment struct {
	ID        int64  `json:"id"`
	ReviewID  int64  `json:"review_id"`
	Body      string `json:"body"`
	Author    string `json:"author"`
	Resolver  string `json:"resolver"`
	URL       string `json:"url"`
	Path      string `json:"path"`
	Line      int64  `json:"line"`
	OldLine   int64  `json:"old_line"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

ReviewComment describes an inline review conversation.

func (ReviewComment) Location

func (c ReviewComment) Location() string

Location names the file and line a comment is on: "app.go:8", or "app.go:4 (old)" for a removed line, which has only an old position.

type ReviewOptions

type ReviewOptions struct {
	Event    string          `json:"event"`
	Body     string          `json:"body"`
	Commit   string          `json:"commit_id,omitempty"`
	Comments []InlineComment `json:"comments,omitempty"`
}

ReviewOptions supplies collected review text and inline comments.

type ReviewRequestChanges

type ReviewRequestChanges struct {
	Add, Remove ReviewRequestInput
}

ReviewRequestChanges adds and removes explicitly named review requests.

func (ReviewRequestChanges) Validate

func (c ReviewRequestChanges) Validate() error

Validate rejects empty, duplicated, and conflicting names before any request.

type ReviewRequestInput

type ReviewRequestInput struct {
	Users []string `json:"reviewers,omitempty"`
	Teams []string `json:"team_reviewers,omitempty"`
}

ReviewRequestInput names users and teams within the repository's organization.

type ReviewSubmitOptions

type ReviewSubmitOptions struct {
	Event string
	Body  *string
}

ReviewSubmitOptions preserves existing draft text when Body is omitted.

type Reviews

type Reviews struct {
	Client     *transport.Client
	Repository string
}

Reviews manages pull request reviews.

func (Reviews) All

func (s Reviews) All(ctx context.Context, n int64) ([]Review, error)

All returns every review of a pull request, including requests for a review.

func (Reviews) ChangeRequests

func (s Reviews) ChangeRequests(ctx context.Context, n int64, changes ReviewRequestChanges) (Pull, error)

ChangeRequests returns the PR after changes and reports partial mutation failures.

func (Reviews) CheckRequestTeams

func (s Reviews) CheckRequestTeams(ctx context.Context, names []string) error

CheckRequestTeams verifies that every named team exists in the repository's organization. Gitea lets only organization members list teams, though outside collaborators and the pull request author may request reviews; when the lookup is forbidden, or the organization is hidden from the caller (a private organization answers 404 to non-members), the server checks the names, as for gh.

func (Reviews) Comments

func (s Reviews) Comments(ctx context.Context, n, reviewID int64, limit, page int) (Page[ReviewComment], error)

Comments flattens the API's unpaginated per-review collections in ID order.

func (Reviews) Create

func (s Reviews) Create(ctx context.Context, n int64, opts ReviewOptions) (Review, error)

Create submits a review.

func (Reviews) Delete

func (s Reviews) Delete(ctx context.Context, n, id int64) error

Delete removes one review.

func (Reviews) Dismiss

func (s Reviews) Dismiss(ctx context.Context, n, id int64, dismiss bool, message string) (Review, error)

Dismiss changes a review's contribution to approval requirements and returns the review.

func (Reviews) Inline

func (s Reviews) Inline(ctx context.Context, n int64, reviews []Review) ([]ReviewComment, error)

Inline returns the inline comments of the given reviews of pull request n.

func (Reviews) List

func (s Reviews) List(ctx context.Context, n int64, limit, page int) ([]Review, error)

List returns a non-nil page of reviews.

func (Reviews) ListPage

func (s Reviews) ListPage(ctx context.Context, n int64, limit, page int) (Page[Review], error)

ListPage lists a window of reviews of pull request n. It reaches past the server's smaller page size, which List would silently take as the whole window.

func (Reviews) Pending

func (s Reviews) Pending(ctx context.Context, n int64, login string) ([]Review, error)

Pending returns the reviews that login started on pull request n and has not submitted yet.

func (Reviews) Reply

func (s Reviews) Reply(ctx context.Context, n, id int64, body string) (ReviewComment, error)

Reply adds a reply to a review comment.

func (Reviews) Resolve

func (s Reviews) Resolve(ctx context.Context, id int64, resolved bool) error

Resolve marks a review conversation resolved or unresolved.

func (Reviews) Submit

func (s Reviews) Submit(ctx context.Context, n, id int64, opts ReviewSubmitOptions) (Review, error)

Submit publishes an existing pending review with explicitly collected input.

func (Reviews) View

func (s Reviews) View(ctx context.Context, n, id int64) (Review, error)

View retrieves a review belonging to the selected pull request.

type Run

type Run struct {
	CreatedAt    string  `json:"created_at"`
	UpdatedAt    string  `json:"updated_at"`
	StartedAt    *string `json:"started_at"`
	CompletedAt  *string `json:"completed_at"`
	ID           int64   `json:"id"`
	RunNumber    int64   `json:"run_number"`
	Title        string  `json:"title"`
	Workflow     string  `json:"workflow"`
	WorkflowPath string  `json:"workflow_path"`
	Status       string  `json:"status"`
	Conclusion   string  `json:"conclusion"`
	URL          string  `json:"url"`
	Branch       string  `json:"branch"`
	Event        string  `json:"event"`
	Actor        string  `json:"actor"`
	Commit       string  `json:"commit"`
	Attempt      int64   `json:"attempt"`
	Jobs         []Job   `json:"jobs,omitzero"`
}

Run is the stable command representation of an Actions run. StartedAt and CompletedAt are nil until the run starts and completes. Workflow is the workflow's name and WorkflowPath its file name; Jobs is only filled where commands show a single run, and JSON leaves it out elsewhere.

func (Run) Completed

func (r Run) Completed() bool

Completed reports whether the run finished, whatever its conclusion.

type RunListOptions

type RunListOptions struct {
	Since, Until                           *time.Time
	Limit, Page                            int
	Branch, Event, Actor, Commit, Workflow string
	Statuses                               []string
}

RunListOptions supplies server-side run filters and pagination. Workflow is a workflow file name.

func (RunListOptions) Validate

func (o RunListOptions) Validate() error

Validate rejects unsupported status filters before performing API requests.

type SSHKey

type SSHKey struct {
	ID          int64  `json:"id"`
	Title       string `json:"title"`
	Key         string `json:"key"`
	Fingerprint string `json:"fingerprint"`
	CreatedAt   string `json:"created_at"`
	ReadOnly    bool   `json:"read_only"`
}

SSHKey describes a public key attached to the selected account.

type SSHKeys

type SSHKeys struct{ Client *transport.Client }

SSHKeys manages public keys for the authenticated account.

func (SSHKeys) All

func (s SSHKeys) All(ctx context.Context) ([]SSHKey, error)

All returns every public key of the account.

func (SSHKeys) Create

func (s SSHKeys) Create(ctx context.Context, title, key string) (SSHKey, error)

Create registers one public key for the account.

func (SSHKeys) Delete

func (s SSHKeys) Delete(ctx context.Context, id int64) error

Delete removes only the selected public key.

func (SSHKeys) List

func (s SSHKeys) List(ctx context.Context, limit, page int) (Page[SSHKey], error)

List returns a page of public keys.

func (SSHKeys) View

func (s SSHKeys) View(ctx context.Context, id int64) (SSHKey, error)

View retrieves a public key of the account by ID. Gitea also answers for other accounts' keys and lets administrators delete them, so a key that belongs to someone else is refused.

type SearchItem

type SearchItem struct {
	ID         int64  `json:"id"`
	Number     int64  `json:"number"`
	Title      string `json:"title"`
	Body       string `json:"body"`
	URL        string `json:"url"`
	State      string `json:"state"`
	Type       string `json:"type"`
	Repository string `json:"repository"`
	Author     string `json:"author"`
	CreatedAt  string `json:"created_at"`
	UpdatedAt  string `json:"updated_at"`
}

SearchItem is shared issue/PR search metadata; ID is Gitea's issue-tracker record ID, including for PRs. Repository and Number identify the resource across search and pull endpoints, which use different internal IDs.

type Status

type Status struct {
	Client     *transport.Client
	Repository string
}

Status reuses search and Actions workflows.

func (Status) Pulls

func (s Status) Pulls(ctx context.Context, limit int) (PullStatus, error)

Pulls collects each category independently; limit applies after repository filtering.

func (Status) Summary

func (s Status) Summary(ctx context.Context, limit int, runsRepository string, discovered bool) (AccountStatus, error)

Summary reports open assigned issues and pull requests and mentions. Failing Actions runs of runsRepository are included when it is set and has Actions enabled. A runsRepository that was only discovered from a clone is left out when the account cannot read it, instead of failing.

type Step

type Step struct {
	Number      int64   `json:"number"`
	Name        string  `json:"name"`
	Status      string  `json:"status"`
	Conclusion  string  `json:"conclusion"`
	StartedAt   *string `json:"started_at"`
	CompletedAt *string `json:"completed_at"`
}

Step is one step of a job. StartedAt and CompletedAt are nil until the step starts and completes.

type Team

type Team struct {
	ID           int64  `json:"id"`
	Name         string `json:"name"`
	Description  string `json:"description"`
	Organization string `json:"organization"`
	// Permission is the team-wide level Gitea reports: owner, admin, read, write, or none for a
	// team that grants its access per unit.
	Permission string `json:"permission"`
	// Access is the team's effective access, as EffectiveAccess summarizes it.
	Access          string            `json:"access"`
	CanCreateRepo   bool              `json:"can_create_repo"`
	AllRepositories bool              `json:"all_repositories"`
	Units           map[string]string `json:"units"`
}

Team is an organization's access group and its permission policy.

func (Team) EffectiveAccess

func (t Team) EffectiveAccess() string

EffectiveAccess summarizes what the team may do in its repositories: owner or admin; the one level it grants, such as write, followed by the units when it does not grant all of them, as in "write (code, issues, pulls)"; none; or custom when it grants different levels.

func (Team) Slug

func (t Team) Slug() string

Slug names the team as ORG/TEAM, or by name alone when its organization is unknown.

func (Team) UnitLevel

func (t Team) UnitLevel(unit string) string

UnitLevel is the access the team has to unit: the higher of the unit's own level and the team permission, which Gitea grants on every unit, capped at the levels the unit allows.

type TeamMember

type TeamMember struct {
	ID       int64  `json:"id"`
	Username string `json:"username"`
	FullName string `json:"full_name"`
}

TeamMember identifies a team member without exposing private profile fields.

type TeamOptions

type TeamOptions struct {
	Name            *string           `json:"name,omitempty"`
	Description     *string           `json:"description,omitempty"`
	Permission      *string           `json:"permission,omitempty"`
	CanCreateRepo   *bool             `json:"can_create_org_repo,omitempty"`
	AllRepositories *bool             `json:"includes_all_repositories,omitempty"`
	Units           map[string]string `json:"units_map,omitempty"`
	// ReplaceUnits makes Edit replace the unit policy with Units instead of merging Units into it.
	ReplaceUnits bool `json:"-"`
}

TeamOptions preserves omitted fields when changing a team.

type TeamSize

type TeamSize struct {
	Members, Repositories *int
}

TeamSize counts the members and repositories of a team; a count the server omits is nil.

type Teams

type Teams struct{ Client *transport.Client }

Teams implements team, member and repository access operations.

func (Teams) ByName

func (s Teams) ByName(ctx context.Context, org string) (map[string]Team, error)

ByName indexes every team of an organization by lower-case name, which Gitea keeps unique.

func (Teams) Create

func (s Teams) Create(ctx context.Context, org string, opts TeamOptions) (Team, error)

Create creates an organization team with explicit initial permissions.

func (Teams) Delete

func (s Teams) Delete(ctx context.Context, id int64) error

Delete deletes a team and its associated access grants.

func (Teams) Edit

func (s Teams) Edit(ctx context.Context, id int64, opts TeamOptions) (Team, error)

Edit merges Units into the current unit policy unless ReplaceUnits is set, and preserves unit permissions when changing access to all repositories. Gitea replaces the whole policy on edit.

func (Teams) Find

func (s Teams) Find(ctx context.Context, org, team string) (Team, error)

Find returns the team of org that team addresses by name or ID, as NameOrID matches them.

func (Teams) IsMember

func (s Teams) IsMember(ctx context.Context, id int64, username string) (bool, error)

IsMember reports whether username belongs to the team.

func (Teams) List

func (s Teams) List(ctx context.Context, org string, limit, page int) (Page[Team], error)

List lists teams in one organization.

func (Teams) Members

func (s Teams) Members(ctx context.Context, id int64, limit, page int) (Page[TeamMember], error)

Members lists members of a team.

func (Teams) Repositories

func (s Teams) Repositories(ctx context.Context, id int64, limit, page int) (Page[Repository], error)

Repositories lists repositories accessible to a team.

func (Teams) SetMember

func (s Teams) SetMember(ctx context.Context, id int64, username string, add bool) error

SetMember adds or removes one team membership.

func (Teams) SetRepository

func (s Teams) SetRepository(ctx context.Context, id int64, repository string, add bool) error

SetRepository adds or removes team access to a repository.

func (Teams) Sizes

func (s Teams) Sizes(ctx context.Context, teams []Team) ([]TeamSize, error)

Sizes counts the members and repositories of each team.

func (Teams) View

func (s Teams) View(ctx context.Context, id int64) (Team, error)

View retrieves a team and its current permissions.

type TimeOptions

type TimeOptions struct {
	Mine          bool
	Issue         int64
	Username      string
	Limit, Page   int
	Since, Before *time.Time
}

TimeOptions supplies an explicit scope, pagination and date filters.

type TimelineEvent

type TimelineEvent struct {
	ID        int64  `json:"id"`
	Type      string `json:"type"`
	Author    string `json:"author"`
	URL       string `json:"url"`
	CreatedAt string `json:"created_at"`
	// Body is the text of comments and reviews.
	Body         *string `json:"body"`
	Label        *string `json:"label"`
	LabelAdded   *bool   `json:"label_added"`
	Milestone    *string `json:"milestone"`
	OldMilestone *string `json:"old_milestone"`
	OldTitle     *string `json:"old_title"`
	NewTitle     *string `json:"new_title"`
	// Assignee is the user an "assignees" event assigned, or the user a "review_request" event
	// asked for a review; RemovedAssignee tells that it unassigned them or withdrew the request.
	Assignee        *string `json:"assignee"`
	RemovedAssignee *bool   `json:"removed_assignee"`
	// DependentIssue is the issue a dependency event added or removed, as OWNER/REPO#NUMBER.
	DependentIssue *string `json:"dependent_issue"`
	// Deadline is the due date, as YYYY-MM-DD, that an "added_deadline" or "modified_deadline"
	// event set; OldDeadline is the one a "modified_deadline" or "removed_deadline" event replaced.
	Deadline    *string `json:"deadline"`
	OldDeadline *string `json:"old_deadline"`
}

TimelineEvent is one entry of an issue's or pull request's timeline: a comment, or a change such as a label, milestone, title or state change, named by Type as Gitea does. Fields an event does not use are nil, so every key is always present in JSON.

type Times

type Times struct {
	Client     *transport.Client
	Repository string
}

Times implements repository and account time tracking.

func (Times) Create

func (s Times) Create(ctx context.Context, n, seconds int64) (TrackedTime, error)

Create records a nonzero number of seconds on one issue.

func (Times) Delete

func (s Times) Delete(ctx context.Context, n, id int64) error

Delete removes one tracked time record from the selected issue.

func (Times) Find

func (s Times) Find(ctx context.Context, n, id int64) (TrackedTime, error)

Find returns the tracked time record id on issue n.

func (Times) ListPage

func (s Times) ListPage(ctx context.Context, opts TimeOptions) (Page[TrackedTime], error)

ListPage returns a non-nil page of tracked time records with their number, as the server counts them.

func (Times) Reset

func (s Times) Reset(ctx context.Context, n int64) (bool, error)

Reset removes the tracked time records of the caller on the selected issue, and reports whether there were any.

type TrackedTime

type TrackedTime struct {
	ID          int64  `json:"id"`
	Seconds     int64  `json:"seconds"`
	CreatedAt   string `json:"created_at"`
	User        string `json:"user"`
	Repository  string `json:"repository"`
	IssueNumber int64  `json:"issue_number"`
	IssueTitle  string `json:"issue_title"`
	IssueURL    string `json:"issue_url"`
}

TrackedTime is a stable record of seconds spent on an issue or pull request.

type UnitError

type UnitError struct {
	Repository string
	// Unit is UnitIssues, UnitPulls, or both.
	Unit string
	// Tracker is the URL of the external issue tracker, if the repository uses one.
	Tracker string
	// Instance is the URL of the repository's instance, when known.
	Instance string
	// NamesInstance makes the hint name Instance, which commands do not find on their own.
	NamesInstance bool
}

UnitError reports a request to issues or pull requests of a repository that has them turned off, or that keeps its issues in an external tracker.

func (*UnitError) Error

func (e *UnitError) Error() string

type Webhook

type Webhook struct {
	ID           int64    `json:"id"`
	Type         string   `json:"type"`
	URL          string   `json:"url"`
	ContentType  string   `json:"content_type"`
	Active       bool     `json:"active"`
	Events       []string `json:"events"`
	BranchFilter string   `json:"branch_filter"`
	CreatedAt    string   `json:"created_at"`
	UpdatedAt    string   `json:"updated_at"`
}

Webhook is webhook metadata. Its delivery URL omits credentials unless revealed; signing secrets and authorization headers are never returned.

type WebhookOptions

type WebhookOptions struct {
	Type          string            `json:"type,omitempty"`
	Config        map[string]string `json:"config,omitempty"`
	Events        *[]string         `json:"events,omitempty"`
	Active        *bool             `json:"active,omitempty"`
	BranchFilter  *string           `json:"branch_filter,omitempty"`
	Authorization *string           `json:"authorization_header,omitempty"`
}

WebhookOptions distinguishes omitted input from explicit empty or false values.

type WebhookScope

type WebhookScope struct {
	Repository, Organization string
	Account, Global          bool
}

WebhookScope selects one repository, organization, account or system scope.

type Webhooks

type Webhooks struct {
	Client *transport.Client
	Scope  WebhookScope
	// RevealURL returns delivery URLs whole, with the credentials they may carry.
	RevealURL bool
}

Webhooks manages hooks without returning delivery credentials.

func (Webhooks) Create

func (s Webhooks) Create(ctx context.Context, opts WebhookOptions) (Webhook, error)

Create registers a new webhook.

func (Webhooks) Delete

func (s Webhooks) Delete(ctx context.Context, id int64) error

Delete removes a webhook from the selected scope.

func (Webhooks) Edit

func (s Webhooks) Edit(ctx context.Context, id int64, opts WebhookOptions) (Webhook, error)

Edit preserves settings that Gitea replaces rather than patching individually.

func (Webhooks) List

func (s Webhooks) List(ctx context.Context, limit, page int) (Page[Webhook], error)

List returns a page of hook metadata.

func (Webhooks) View

func (s Webhooks) View(ctx context.Context, id int64) (Webhook, error)

View retrieves hook metadata without exposing its delivery configuration.

type Wiki

type Wiki struct {
	Client     *transport.Client
	Repository string
}

Wiki implements repository wiki operations.

func (Wiki) Create

func (s Wiki) Create(ctx context.Context, opts WikiOptions) (WikiPage, error)

Create creates one wiki page, initializing the wiki if necessary.

func (Wiki) Delete

func (s Wiki) Delete(ctx context.Context, name string) error

Delete removes a named wiki page.

func (Wiki) Edit

func (s Wiki) Edit(ctx context.Context, name string, opts WikiOptions) (WikiPage, bool, error)

Edit replaces page content and optionally changes its title. It reports whether the title changed. Gitea's edit creates a page that does not exist and overwrites one the new title names, so both are checked first.

func (Wiki) ListPage

func (s Wiki) ListPage(ctx context.Context, limit, page int) (Page[WikiPage], error)

ListPage lists a page of wiki pages, with whether more follow and, when the whole wiki was read, how many there are. Gitea windows the wiki's files, not its pages: a window holds fewer pages than its size, or none, while later windows still hold pages. The windows are read in order while the server links a next one, until one page past the requested page is found.

func (Wiki) Revisions

func (s Wiki) Revisions(ctx context.Context, name string, page int) (Page[WikiRevision], error)

Revisions returns one server-paginated page of wiki commits and the total the server counted.

func (Wiki) View

func (s Wiki) View(ctx context.Context, name string) (WikiPage, error)

View retrieves and decodes a wiki page.

type WikiOptions

type WikiOptions struct{ Title, Body, Message string }

WikiOptions supplies title, decoded content and a commit message.

type WikiPage

type WikiPage struct {
	Title       string `json:"title"`
	Body        string `json:"body"`
	URL         string `json:"url"`
	SHA         string `json:"sha"`
	Author      string `json:"author"`
	UpdatedAt   string `json:"updated_at"`
	CommitCount int64  `json:"commit_count"`
	Sidebar     string `json:"sidebar"`
	Footer      string `json:"footer"`
	// contains filtered or unexported fields
}

WikiPage exposes decoded page content and revision metadata. Gitea lists pages without their content, so the JSON of a listed page leaves out body, commit_count, sidebar and footer rather than report them empty.

func (WikiPage) MarshalJSON

func (p WikiPage) MarshalJSON() ([]byte, error)

MarshalJSON leaves the content fields out of a listed page.

type WikiRevision

type WikiRevision struct {
	SHA       string `json:"sha"`
	Message   string `json:"message"`
	Author    string `json:"author"`
	CreatedAt string `json:"created_at"`
}

WikiRevision represents a wiki commit without exposing author email addresses.

type Workflow

type Workflow struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Path  string `json:"path"`
	State string `json:"state"`
	URL   string `json:"url"`
}

Workflow is the stable command representation of an Actions workflow. ID is its file name, such as ci.yml.

func FindWorkflow

func FindWorkflow(items []Workflow, raw, scope string) (Workflow, error)

FindWorkflow returns the workflow among items that raw names, like Actions.FindWorkflow. It fails with a *NotFoundError when none matches and lists the files when several names match.

func (Workflow) Enabled

func (w Workflow) Enabled() bool

Enabled reports whether the workflow runs; Gitea reports a disabled one as disabled_manually.

func (Workflow) Label

func (w Workflow) Label() string

Label names the workflow for people: "CI (ci.yml)".

type WorkflowInput

type WorkflowInput struct {
	Name, Description string
	// Type is string, choice, boolean, number or environment; empty means string.
	Type, Default string
	Required      bool
	Options       []string
}

WorkflowInput is one input that a workflow's workflow_dispatch trigger declares.

func DispatchInputs

func DispatchInputs(definition []byte) ([]WorkflowInput, error)

DispatchInputs parses the inputs that the workflow_dispatch trigger of a workflow definition declares, in their order. It fails with ErrNoDispatch when the workflow cannot be dispatched.

Jump to

Keyboard shortcuts

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