services

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 30 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 or project 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 ErrNoStopwatch = errors.New("no stopwatch is running")

ErrNoStopwatch reports that the account has no stopwatch running on an issue.

View Source
var ErrOrganizationFeedPerformedBy = errors.New("the feed of an organization cannot be narrowed to what it did")

ErrOrganizationFeedPerformedBy reports an OnlyPerformedBy scope whose owner is an organization, whose feed Gitea cannot narrow that way.

View Source
var ErrPullUpToDate = errors.New("the head branch already has the commits of the base branch")

ErrPullUpToDate reports a head branch that already has every commit of its base branch.

View Source
var ErrPullUpdateConflicts = errors.New("the head branch conflicts with the base branch")

ErrPullUpdateConflicts reports a head branch that cannot take the commits of its base branch without conflicts.

View Source
var ErrRebaseUpdateDisabled = errors.New("the repository does not allow rebase updates")

ErrRebaseUpdateDisabled reports a repository that does not allow updating a head branch by rebasing it.

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 ErrTagProtectionNeedsAllowed = errors.New("a tag protection rule needs at least one user or team that may create the tags")

ErrTagProtectionNeedsAllowed is the failure to add a tag protection rule that lets nobody create tags.

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 ProjectWorkflowEvents = []string{
	"item_added_to_project", "item_removed_from_project", "item_reopened", "item_closed", "item_column_changed",
	"code_changes_requested", "code_review_approved", "pull_request_merged",
}

ProjectWorkflowEvents are the events a project workflow can run on.

View Source
var RunStatuses = []string{"queued", "in_progress", "waiting", "requested", "pending", "action_required", "completed", "success", "failure", "cancelled", "skipped", "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 MissingSudoUser added in v1.0.0

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

MissingSudoUser returns a *NotFoundError when the Sudo user of client does not exist, which Gitea answers like any missing resource, with a bare 404.

func OfficialApprovals

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

OfficialApprovals counts the reviewers whose effective 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 effective review requests changes, else approved when one approves, else review_required while reviews are requested, else "". 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.

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) (SetActionSecret, 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) FindWorkflowAt added in v1.0.0

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

FindWorkflowAt returns the workflow that raw names as Gitea runs it at ref, from the first of workflowDirs that exists there, or that FindWorkflow returns when ref is empty. A file that the server lists keeps its name and state.

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. A server that cannot list workflows or jobs gets the run without them, with a *CapabilityError for each.

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.

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. A server that cannot list workflows gets the runs with a *CapabilityError.

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) WorkflowAt added in v1.0.0

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

WorkflowAt returns the workflow that raw names among the workflow files at ref, like FindWorkflow; the server lists workflows of the default branch only.

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 Activities added in v1.2.0

type Activities struct{ Client *transport.Client }

Activities reads activity feeds.

func (Activities) ListPage added in v1.2.0

func (s Activities) ListPage(ctx context.Context, scope ActivityScope, limit, page int) (Page[Activity], error)

ListPage lists a page of a feed, newest first.

type Activity added in v1.2.0

type Activity struct {
	ID int64 `json:"id"`
	// Type is what was done, as Gitea names it: create_issue, comment_pull, commit_repo and so on.
	Type       string `json:"type"`
	Actor      string `json:"actor"`
	Repository string `json:"repository"`
	// Ref is the branch or tag that the entry is about, as refs/heads/main.
	Ref string `json:"ref"`
	// Content is what Gitea records of it: "12|Title" for an issue or pull request, JSON for a push.
	Content   string `json:"content"`
	Private   bool   `json:"private"`
	CommentID int64  `json:"comment_id"`
	CreatedAt string `json:"created_at"`
}

Activity is one entry of an activity feed: something that someone did.

type ActivityScope added in v1.2.0

type ActivityScope struct {
	Repository, Owner string
	// Date keeps the entries of one day, as YYYY-MM-DD.
	Date string
	// OnlyPerformedBy keeps, in the feed of a user, what that user did, leaving out what happened in
	// repositories they watch.
	OnlyPerformedBy bool
}

ActivityScope selects a feed: the repository's, else that of Owner, a user or an organization, else that of the account of the client.

type AdminBadge added in v1.1.0

type AdminBadge struct {
	ID          int64  `json:"id"`
	Slug        string `json:"slug"`
	Description string `json:"description"`
	ImageURL    string `json:"image_url"`
}

AdminBadge is a badge that can be awarded to accounts.

type AdminCron added in v1.1.0

type AdminCron struct{ Client *transport.Client }

AdminCron lists and starts the scheduled tasks.

func (AdminCron) List added in v1.1.0

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

List returns a page of scheduled tasks.

func (AdminCron) Run added in v1.1.0

func (s AdminCron) Run(ctx context.Context, task string) error

Run starts a scheduled task now.

type AdminEmail added in v1.1.0

type AdminEmail struct {
	Email    string `json:"email"`
	Username string `json:"username"`
	UserID   int64  `json:"user_id"`
	Primary  bool   `json:"primary"`
	Verified bool   `json:"verified"`
}

AdminEmail is an email address of an account.

type AdminEmails added in v1.1.0

type AdminEmails struct{ Client *transport.Client }

AdminEmails lists the email addresses of all accounts.

func (AdminEmails) List added in v1.1.0

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

List returns a page of the addresses whose address, username or full name contains query, or of every address without one.

type AdminOrganizations added in v1.1.0

type AdminOrganizations struct{ Client *transport.Client }

AdminOrganizations provides instance-wide organization operations for administrators.

func (AdminOrganizations) Create added in v1.1.0

Create creates an organization owned by another user.

func (AdminOrganizations) List added in v1.1.0

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

List returns a page of every organization of the instance, private ones included.

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) AddBadges added in v1.1.0

func (s AdminUsers) AddBadges(ctx context.Context, username string, slugs []string) error

AddBadges awards badges, named by slug, to an account.

func (AdminUsers) Badges added in v1.1.0

func (s AdminUsers) Badges(ctx context.Context, username string) ([]AdminBadge, error)

Badges lists the badges of an account.

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) CreateKey added in v1.1.0

func (s AdminUsers) CreateKey(ctx context.Context, username, title, key string) (SSHKey, error)

CreateKey adds a public key to another account.

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) DeleteKey added in v1.1.0

func (s AdminUsers) DeleteKey(ctx context.Context, username string, id int64) error

DeleteKey removes a public key of another account.

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) RemoveBadges added in v1.1.0

func (s AdminUsers) RemoveBadges(ctx context.Context, username string, slugs []string) error

RemoveBadges takes badges, named by slug, from an account.

func (AdminUsers) Rename added in v1.1.0

func (s AdminUsers) Rename(ctx context.Context, username, newUsername string) error

Rename changes the username of an account.

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 columns, 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 BranchRule added in v1.2.0

type BranchRule 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"`
	// PushEnabled is false when nobody may push directly. PushRestricted limits it to PushUsers,
	// PushTeams and, when PushDeployKeys is set, deploy keys; otherwise everyone with write access may.
	PushEnabled    bool     `json:"push_enabled"`
	PushRestricted bool     `json:"push_restricted"`
	PushUsers      []string `json:"push_users"`
	PushTeams      []string `json:"push_teams"`
	PushDeployKeys bool     `json:"push_deploy_keys"`
	// ForcePush lets those who may push do it with force, limited to the force push users, teams and,
	// when ForcePushDeployKeys is set, deploy keys when ForcePushRestricted is set.
	ForcePush           bool     `json:"force_push"`
	ForcePushRestricted bool     `json:"force_push_restricted"`
	ForcePushUsers      []string `json:"force_push_users"`
	ForcePushTeams      []string `json:"force_push_teams"`
	ForcePushDeployKeys bool     `json:"force_push_deploy_keys"`
	// MergeRestricted limits who may merge pull requests to MergeUsers and MergeTeams.
	MergeRestricted bool     `json:"merge_restricted"`
	MergeUsers      []string `json:"merge_users"`
	MergeTeams      []string `json:"merge_teams"`
	// StatusChecks must pass before pull requests merge when StatusCheckRequired is set; with none
	// listed, Gitea requires every check reported on the commit to pass.
	StatusCheckRequired bool     `json:"status_check_required"`
	StatusChecks        []string `json:"status_checks"`
	// ApprovalUsers and ApprovalTeams are those whose approvals count, when ApprovalsRestricted is set.
	ApprovalsRestricted           bool     `json:"approvals_restricted"`
	ApprovalUsers                 []string `json:"approval_users"`
	ApprovalTeams                 []string `json:"approval_teams"`
	BlockOnRejected               bool     `json:"block_on_rejected_reviews"`
	BlockOnOfficialReviewRequests bool     `json:"block_on_official_review_requests"`
	BlockOnOutdatedBranch         bool     `json:"block_on_outdated_branch"`
	DismissStaleApprovals         bool     `json:"dismiss_stale_approvals"`
	IgnoreStaleApprovals          bool     `json:"ignore_stale_approvals"`
	RequireSignedCommits          bool     `json:"require_signed_commits"`
	BlockAdminMergeOverride       bool     `json:"block_admin_merge_override"`
	ProtectedFilePatterns         string   `json:"protected_file_patterns"`
	UnprotectedFilePatterns       string   `json:"unprotected_file_patterns"`
	CreatedAt                     string   `json:"created_at"`
	UpdatedAt                     string   `json:"updated_at"`
}

BranchRule is a branch protection rule as Gitea returns it. Protection holds the few settings that gt branch protect changes.

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) Protection added in v1.2.0

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

Protection returns the rule named rule, a branch name or the pattern it was made with.

func (Branches) Protections added in v1.2.0

func (s Branches) Protections(ctx context.Context, repo string) ([]BranchRule, error)

Protections lists the protection rules of a repository, in the order that Gitea applies them. Gitea answers all of them at once and ignores page and limit.

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, or from the server.

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) Attachment added in v1.0.0

func (s Comments) Attachment(ctx context.Context, id, attachmentID int64) (IssueAttachment, error)

Attachment retrieves metadata for one attachment of comment id.

func (Comments) Attachments added in v1.0.0

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

Attachments paginates the unpaginated attachments of comment id locally.

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) DeleteAttachment added in v1.0.0

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

DeleteAttachment removes one attachment from comment id.

func (Comments) DownloadAttachment added in v1.0.0

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

DownloadAttachment retrieves the metadata of an attachment of comment id and returns a function that opens its content, as Issues.DownloadAttachment does.

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) RenameAttachment added in v1.0.0

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

RenameAttachment changes the filename of an attachment of comment id without replacing its content.

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 Commit added in v1.2.0

type Commit struct {
	SHA            string   `json:"sha"`
	Message        string   `json:"message"`
	Author         string   `json:"author"`
	AuthorEmail    string   `json:"author_email"`
	AuthorLogin    string   `json:"author_login"`
	Committer      string   `json:"committer"`
	CommitterEmail string   `json:"committer_email"`
	CommitterLogin string   `json:"committer_login"`
	AuthoredAt     string   `json:"authored_at"`
	CommittedAt    string   `json:"committed_at"`
	URL            string   `json:"url"`
	Parents        []string `json:"parents"`
	// Verified and VerificationReason tell whether Gitea could check the signature of the commit.
	Verified           bool   `json:"verified"`
	VerificationReason string `json:"verification_reason"`
	// Additions, Deletions and Files are read only when asked for: a list leaves them out unless
	// the output includes them.
	Additions int      `json:"additions"`
	Deletions int      `json:"deletions"`
	Files     []string `json:"files"`
}

Commit is a commit of a repository.

type CommitListOptions added in v1.2.0

type CommitListOptions struct {
	// Ref is the branch, tag or commit to list from; the default branch when empty.
	Ref string
	// Path keeps the commits that changed this file or directory.
	Path string
	// Not leaves out the commits reachable from this ref.
	Not string
	// Stat, Files and Verification add what costs the server extra work to read.
	Stat, Files, Verification bool
}

CommitListOptions selects the commits of a listing.

type Commits added in v1.2.0

type Commits struct{ Client *transport.Client }

Commits reads the commits of repositories.

func (Commits) Compare added in v1.2.0

func (s Commits) Compare(ctx context.Context, repo, base, head string) (Comparison, error)

Compare lists the commits that head has and base has not.

func (Commits) Diff added in v1.2.0

func (s Commits) Diff(ctx context.Context, repo, ref string, patch bool) ([]byte, error)

Diff returns the unified diff of a commit; with patch it is the patch that git am takes, with the message and author.

func (Commits) List added in v1.2.0

func (s Commits) List(ctx context.Context, repo string, opts CommitListOptions, limit, page int) (Page[Commit], error)

List lists a page of commits, newest first.

func (Commits) PullRequestOf added in v1.2.0

func (s Commits) PullRequestOf(ctx context.Context, repo, sha string) (Pull, error)

PullRequestOf returns the pull request that merged a commit, if any.

func (Commits) Status added in v1.2.0

func (s Commits) Status(ctx context.Context, repo, ref string) ([]Check, error)

Status returns the latest status of each check context of a commit, read in full: the combined status of Gitea covers only its first page.

func (Commits) View added in v1.2.0

func (s Commits) View(ctx context.Context, repo, ref string) (Commit, error)

View returns a commit, named by its SHA, a branch or a tag, with the files it changed.

type Comparison added in v1.2.0

type Comparison struct {
	Base         string   `json:"base"`
	Head         string   `json:"head"`
	TotalCommits int      `json:"total_commits"`
	Commits      []Commit `json:"commits"`
}

Comparison is what a ref has that another has not: the commits between them.

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 CronTask added in v1.1.0

type CronTask struct {
	Name      string `json:"name"`
	Schedule  string `json:"schedule"`
	Next      string `json:"next"`
	Prev      string `json:"prev"`
	ExecTimes int64  `json:"exec_times"`
}

CronTask is a scheduled background task of the instance.

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 ElsewhereError added in v1.0.0

type ElsewhereError struct {
	ID                   int64
	Repository, Selected string
}

ElsewhereError reports a notification of another repository than the selected one.

func (*ElsewhereError) Error added in v1.0.0

func (e *ElsewhereError) 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 GPGKey added in v1.1.0

type GPGKey struct {
	ID                int64         `json:"id"`
	KeyID             string        `json:"key_id"`
	PrimaryKeyID      string        `json:"primary_key_id"`
	PublicKey         string        `json:"public_key"`
	Emails            []GPGKeyEmail `json:"emails"`
	Subkeys           []string      `json:"subkeys"`
	CanSign           bool          `json:"can_sign"`
	CanEncryptComms   bool          `json:"can_encrypt_comms"`
	CanEncryptStorage bool          `json:"can_encrypt_storage"`
	CanCertify        bool          `json:"can_certify"`
	Verified          bool          `json:"verified"`
	CreatedAt         string        `json:"created_at"`
	ExpiresAt         string        `json:"expires_at"`
}

GPGKey describes a GPG public key attached to the selected account.

type GPGKeyEmail added in v1.1.0

type GPGKeyEmail struct {
	Email    string `json:"email"`
	Verified bool   `json:"verified"`
}

GPGKeyEmail is an email address of a GPG key and whether Gitea accepts it for the account.

type GPGKeys added in v1.1.0

type GPGKeys struct{ Client *transport.Client }

GPGKeys manages GPG public keys for the authenticated account.

func (GPGKeys) Create added in v1.1.0

func (s GPGKeys) Create(ctx context.Context, armored, signature string) (GPGKey, error)

Create registers an armored GPG public key for the account. signature, an armored signature of the token of Token, proves control of a key without an activated email address of the account.

func (GPGKeys) Delete added in v1.1.0

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

Delete removes only the selected GPG key.

func (GPGKeys) List added in v1.1.0

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

List returns a page of GPG keys.

func (GPGKeys) Token added in v1.1.0

func (s GPGKeys) Token(ctx context.Context) (GPGToken, error)

Token returns the text to sign with a GPG key to verify it.

func (GPGKeys) Verify added in v1.1.0

func (s GPGKeys) Verify(ctx context.Context, keyID, signature string) (GPGKey, error)

Verify proves control of the GPG key keyID with the armored signature of the token.

func (GPGKeys) View added in v1.1.0

func (s GPGKeys) View(ctx context.Context, id int64) (GPGKey, error)

View retrieves a GPG key of the account by ID.

type GPGToken added in v1.1.0

type GPGToken struct {
	Token string `json:"token"`
}

GPGToken is the text that proves control of a GPG key once it is signed with it.

type Gitignore added in v1.1.0

type Gitignore struct {
	Name   string `json:"name"`
	Source string `json:"source"`
}

Gitignore is a .gitignore template with its content.

type GitignoreEntry added in v1.1.0

type GitignoreEntry struct {
	Name string `json:"name"`
}

GitignoreEntry is the name of a .gitignore template.

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"`
	Locked    bool            `json:"-"`
}

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, or against the labels of an organization.

func (IssueLabelCatalog) Name added in v1.1.0

func (c IssueLabelCatalog) Name(id int64) (string, bool)

Name returns the name of the label id, or false when the catalog lacks it.

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.

func (IssueLabelCatalog) ResolveOrID added in v1.1.0

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

ResolveOrID is Resolve that also takes the ID of a label in the catalog for a name that matches none.

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) Delete added in v1.1.0

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

Delete deletes an issue for good, with its comments.

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) Find added in v1.0.0

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

Find is Kind, but a number Gitea does not show fails with a *NotFoundError, of the repository when that is missing, unless the repository keeps its issues in an external tracker.

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) SetBlocks added in v1.1.0

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

SetBlocks makes issue n block issue blocked, which may belong to another repository where the instance allows that, or with block false lifts that. It is SetBlockedBy the other way round.

func (Issues) SetLocked added in v1.1.0

func (s Issues) SetLocked(ctx context.Context, number int64, locked bool, reason string) error

SetLocked locks the conversation of an issue or pull request, or unlocks it. Gitea does nothing when it is in that state already. reason is free text: Gitea does not check it against the reasons that its settings offer.

func (Issues) SetPinned added in v1.1.0

func (s Issues) SetPinned(ctx context.Context, number int64, pinned bool) error

SetPinned pins an issue or pull request to the top of its list, or unpins it.

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: those of the repository and of the organization that owns it, or those of the organization of an organization scope.

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 License added in v1.1.0

type License struct {
	Key            string `json:"key"`
	Name           string `json:"name"`
	URL            string `json:"url"`
	Body           string `json:"body"`
	Implementation string `json:"implementation"`
}

License is a license with its text.

type LicenseEntry added in v1.1.0

type LicenseEntry struct {
	Key  string `json:"key"`
	Name string `json:"name"`
	URL  string `json:"url"`
}

LicenseEntry is a license that Gitea offers for new repositories.

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
	// Force merges although the branch protection is not met, if Gitea lets the user bypass it.
	Force 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
	// Commit is the commit that merged the pull request outside Gitea, for the manually-merged method.
	Commit 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"`
	URL          string  `json:"url"`
	Deadline     *string `json:"due_date"`
	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 Moved added in v1.0.0

type Moved struct {
	Issue           Issue
	Project, Column string
	Unchanged       bool
}

Moved is where Move left an issue: the column Column of the project Project. Unchanged says it was there already, so that nothing was sent.

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
}

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]) CreateUnique added in v1.0.0

func (n NameOrID[T]) CreateUnique(existing []T, name string, update bool, create func() (T, error), edit func(T) (T, error)) (T, bool, error)

CreateUnique runs create unless an item among existing has name, ignoring case, which names would then no longer address. With update it runs edit on that item instead and reports true; otherwise a *ConflictError refuses it.

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.

func (NameOrID[T]) FindAll added in v1.0.0

func (n NameOrID[T]) FindAll(items []T, raws []string) ([]T, error)

FindAll returns the items among items that raws address, each like Find.

func (NameOrID[T]) RefuseRename added in v1.0.0

func (n NameOrID[T]) RefuseRename(existing []T, current T, name string) error

RefuseRename refuses to rename current to name when another item among existing has it, ignoring case, which CreateUnique refuses too: names would no longer address either item.

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 NotTemplateError added in v1.0.0

type NotTemplateError struct {
	Repository string
	Err        error
}

NotTemplateError reports a source of Generate that is not marked as a template repository.

func (*NotTemplateError) Error added in v1.0.0

func (e *NotTemplateError) Error() string

func (*NotTemplateError) Unwrap added in v1.0.0

func (e *NotTemplateError) 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, bool, error)

LatestComment returns the latest comment on the subject of a notification and whether it exists.

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, bool, error)

RepositoryCount counts the repositories of an organization and reports whether the count is available.

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 OwnerScope added in v1.0.0

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

OwnerScope selects the webhooks or Actions runners of one repository, organization, account or the instance.

func (OwnerScope) String added in v1.0.0

func (s OwnerScope) String() string

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

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) (bool, error)

Link links a package to a repository of its owner, or with repository empty unlinks it. It reports false without a change when the package is linked to that repository already, or when it is to be unlinked and has no repository.

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.

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 Project added in v1.0.0

type Project struct {
	ID           int64  `json:"id"`
	Title        string `json:"title"`
	Description  string `json:"description"`
	State        string `json:"state"`
	Type         string `json:"type"`
	CardType     string `json:"card_type"`
	OpenIssues   int64  `json:"open_issues"`
	ClosedIssues int64  `json:"closed_issues"`
	URL          string `json:"url"`
	CreatedAt    string `json:"created_at"`
	UpdatedAt    string `json:"updated_at"`
}

Project is a stable project board result.

type ProjectBoards added in v1.0.0

type ProjectBoards struct {
	Client                   *transport.Client
	Repository, Organization string
	Account                  bool
}

ProjectBoards manages the projects of a repository or, with Organization or Account, of an organization or of the authenticated user.

func (ProjectBoards) All added in v1.0.0

func (s ProjectBoards) All(ctx context.Context) ([]Project, error)

All returns every project in the scope, whatever its state.

func (ProjectBoards) Columns added in v1.1.0

func (s ProjectBoards) Columns(ctx context.Context, project Project) ([]ProjectColumn, error)

Columns returns the columns of project.

func (ProjectBoards) Create added in v1.0.0

func (s ProjectBoards) Create(ctx context.Context, opts ProjectOptions) (Project, error)

Create creates one project.

func (ProjectBoards) CreateUnique added in v1.0.0

func (s ProjectBoards) CreateUnique(ctx context.Context, existing []Project, opts ProjectOptions, update bool) (Project, bool, error)

CreateUnique creates a project unless one among existing, the projects of the scope, has its title, ignoring case, which titles would then no longer address. With update it edits that project instead and reports true.

func (ProjectBoards) CreateWorkflow added in v1.1.0

func (s ProjectBoards) CreateWorkflow(ctx context.Context, project Project, opts ProjectWorkflowOptions) (ProjectWorkflow, error)

CreateWorkflow adds a workflow to project.

func (ProjectBoards) Delete added in v1.0.0

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

Delete deletes one project.

func (ProjectBoards) DeleteWorkflow added in v1.1.0

func (s ProjectBoards) DeleteWorkflow(ctx context.Context, project Project, id int64) error

DeleteWorkflow removes a workflow from project.

func (ProjectBoards) Edit added in v1.0.0

func (s ProjectBoards) Edit(ctx context.Context, id int64, opts ProjectOptions) (Project, error)

Edit updates only explicitly supplied fields.

func (ProjectBoards) EditUnique added in v1.0.0

func (s ProjectBoards) EditUnique(ctx context.Context, existing []Project, current Project, opts ProjectOptions) (Project, error)

EditUnique edits current like Edit but refuses to retitle it to the title of another project among existing, ignoring case, which CreateUnique refuses too.

func (ProjectBoards) EditWorkflow added in v1.1.0

func (s ProjectBoards) EditWorkflow(ctx context.Context, project Project, id int64, opts ProjectWorkflowOptions) (ProjectWorkflow, error)

EditWorkflow changes the supplied fields of a workflow of project.

func (ProjectBoards) Find added in v1.0.0

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

Find returns the projects that raws address, each by ID or title; byName matches numeric values as titles only.

func (ProjectBoards) FindIn added in v1.0.0

func (s ProjectBoards) FindIn(items []Project, raw string, byName bool) (Project, error)

FindIn returns the project among items, the projects of the scope, that raw addresses like Find.

func (ProjectBoards) LabelCatalog added in v1.1.0

func (s ProjectBoards) LabelCatalog(ctx context.Context) (IssueLabelCatalog, error)

LabelCatalog loads the labels that the workflows of the projects can name: a repository project's come from its repository and the organization that owns it, an organization project's from the organization.

func (ProjectBoards) ListPage added in v1.0.0

func (s ProjectBoards) ListPage(ctx context.Context, state string, limit, page int) (Page[Project], error)

ListPage returns one page of the projects in state: open, closed or all.

func (ProjectBoards) Scope added in v1.0.0

func (s ProjectBoards) Scope() string

Scope names the repository, organization or account the projects belong to.

func (ProjectBoards) Workflow added in v1.1.0

func (s ProjectBoards) Workflow(ctx context.Context, project Project, id int64) (ProjectWorkflow, error)

Workflow returns one workflow of project.

func (ProjectBoards) Workflows added in v1.1.0

func (s ProjectBoards) Workflows(ctx context.Context, project Project) ([]ProjectWorkflow, error)

Workflows returns every workflow of project.

type ProjectColumn added in v1.1.0

type ProjectColumn struct {
	ID    int64
	Title string
}

ProjectColumn is a column of a project board.

func FindColumn added in v1.1.0

func FindColumn(columns []ProjectColumn, name string) (ProjectColumn, error)

FindColumn matches name against columns by ID, then by title, then ignoring case, spaces and punctuation, so that "in-progress" finds "In progress".

type ProjectOptions added in v1.0.0

type ProjectOptions struct {
	Title       *string
	Description *string
	CardType    *string
	State       *string
	Template    string
}

ProjectOptions distinguishes omitted project fields during edits. Template applies to new projects only.

type ProjectWorkflow added in v1.1.0

type ProjectWorkflow struct {
	ID        int64                  `json:"id"`
	Event     string                 `json:"event"`
	Enabled   bool                   `json:"enabled"`
	Filters   ProjectWorkflowFilters `json:"filters"`
	Actions   ProjectWorkflowActions `json:"actions"`
	CreatedAt string                 `json:"created_at"`
	UpdatedAt string                 `json:"updated_at"`
}

ProjectWorkflow is a stable project workflow result.

type ProjectWorkflowActions added in v1.1.0

type ProjectWorkflowActions struct {
	ColumnID       int64   `json:"column_id,omitempty"`
	AddLabelIDs    []int64 `json:"add_label_ids,omitempty"`
	RemoveLabelIDs []int64 `json:"remove_label_ids,omitempty"`
	IssueState     string  `json:"issue_state,omitempty"`
}

ProjectWorkflowActions are what a project workflow does to a matching item.

type ProjectWorkflowFilters added in v1.1.0

type ProjectWorkflowFilters struct {
	IssueType      string  `json:"issue_type,omitempty"`
	SourceColumnID int64   `json:"source_column_id,omitempty"`
	TargetColumnID int64   `json:"target_column_id,omitempty"`
	LabelIDs       []int64 `json:"label_ids,omitempty"`
}

ProjectWorkflowFilters restricts the items a project workflow runs for.

type ProjectWorkflowOptions added in v1.1.0

type ProjectWorkflowOptions struct {
	Event   string
	Enabled *bool
	Filters *ProjectWorkflowFilters
	Actions *ProjectWorkflowActions
}

ProjectWorkflowOptions distinguishes omitted fields: a nil Filters or Actions is left as it is on edit. Event applies to creation only.

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 or user 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, refs []string, withIssues bool) ([]Board, error)

Boards resolves the open projects that refs name by ID or title: a number is an ID before it is a title, and a title's case matters only to tell two projects apart. Titles are looked up in the repository's projects, else its owner'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) Move added in v1.0.0

func (s Projects) Move(ctx context.Context, number int64, column, project string) (Moved, error)

Move puts the issue number in a column of the open project board that holds it. project selects the board by ID or title, which an issue on several needs; it is otherwise found among the open projects the issue is on.

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"`
	// MergeBase is the commit of the base branch the pull request's own commits start from.
	MergeBase string `json:"-"`
	Locked    bool   `json:"-"`
	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"`
	BaseSHA           string `json:"-"`
	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:"-"`
	BaseCanPush         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 must all be on a pull request. Gitea's filter matches any of them, and repeats a pull
	// request for each one it has, so List checks more than one itself.
	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) CancelAutoMerge added in v1.2.0

func (s Pulls) CancelAutoMerge(ctx context.Context, n int64) (bool, error)

CancelAutoMerge cancels the merge that Gitea scheduled for when the checks succeed. It reports false when none was scheduled, which Gitea answers with a bare 404 like that of a missing pull request: the caller has found the pull request already.

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, required bool) ([]Check, error)

Checks returns latest contexts for the PR head in its base repository, as Gitea does; with required, only those that the protection of the base branch requires.

func (Pulls) ClosedSince added in v1.0.0

func (s Pulls) ClosedSince(ctx context.Context, since time.Time) ([]Pull, error)

ClosedSince returns the closed and merged pull requests, most recently updated first, reading pages until one ends with a pull request last updated before since.

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) HeadMoved added in v1.0.0

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

HeadMoved reports whether the head branch of item has commits beyond the pull request: Gitea reports the branch's tip as its head, but keeps the commit the pull request was merged or closed at in its pull ref.

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) OtherOpenWithHead added in v1.0.0

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

OtherOpenWithHead returns an open pull request other than item from the same head branch, which deleting that branch would close, and whether there is one.

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) UpdateBranch added in v1.0.0

func (s Pulls) UpdateBranch(ctx context.Context, pull Pull, rebase bool) error

UpdateBranch brings the new commits of the base branch of pull into its head branch, with a merge commit, or with rebase by rebasing the head branch onto the base branch.

func (Pulls) View

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

View retrieves one pull request.

func (Pulls) ViewWithReviews added in v1.2.0

func (s Pulls) ViewWithReviews(ctx context.Context, n int64) (Pull, []Review, error)

ViewWithReviews reads pull request n and its reviews together.

func (Pulls) WatchChecks

func (s Pulls) WatchChecks(ctx context.Context, n int64, interval time.Duration, required bool, 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 RegistrationToken added in v1.0.0

type RegistrationToken struct {
	Token string `json:"token"`
}

RegistrationToken lets a runner register itself with the scope.

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.

func (Release) When added in v1.2.0

func (r Release) When() string

When is when a release was published, or created for a draft.

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 ReleaseListOptions added in v1.2.0

type ReleaseListOptions struct {
	// ExcludeDrafts and ExcludePrereleases leave those out, which Gitea does itself.
	ExcludeDrafts, ExcludePrereleases bool
	// Order is "asc" or "desc" to sort the releases by when they were made, oldest or newest first, or ""
	// for the order of Gitea, the newest first. Gitea sorts no other way, so asc reads every
	// release and sorts them here.
	Order string
}

ReleaseListOptions narrows a listing of releases.

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.

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, current Release, opts ReleaseOptions) (Release, error)

Edit changes only supplied release fields of current; 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, opts ReleaseListOptions) (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) TagCommit added in v1.0.0

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

TagCommit returns the SHA of the commit that tag points at.

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) Commit added in v1.0.0

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

Commit resolves ref, a branch, tag or commit, to the full commit SHA.

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) CreateChoices added in v0.2.0

func (s Repositories) CreateChoices(ctx context.Context) (RepositoryCreateChoices, error)

CreateChoices loads the choices of interactive repository creation.

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) File added in v1.0.0

func (s Repositories) File(ctx context.Context, repo, ref, path string) ([]byte, bool, error)

File returns the content of the file at path in the repository at ref, and whether it exists.

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 RepositoryCreateChoices added in v0.2.0

type RepositoryCreateChoices struct {
	Organizations, Licenses, Gitignores []string
}

RepositoryCreateChoices are what interactive repository creation offers: the organizations of the account and the server's license and .gitignore templates.

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"`
	ManualMerge    *bool   `json:"allow_manual_merge,omitempty"`
	DetectMerge    *bool   `json:"autodetect_manual_merge,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 EffectiveReviews added in v0.2.0

func EffectiveReviews(reviews []Review) []Review

EffectiveReviews returns each reviewer's review in effect, in the order of their first review: their latest, except that a comment review leaves an earlier one of another state in effect, as in Gitea, where only an approval or a dismissal lifts a request for changes.

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 Runner added in v1.0.0

type Runner struct {
	ID        int64    `json:"id"`
	Name      string   `json:"name"`
	Status    string   `json:"status"`
	Busy      bool     `json:"busy"`
	Disabled  bool     `json:"disabled"`
	Ephemeral bool     `json:"ephemeral"`
	Labels    []string `json:"labels"`
}

Runner is an Actions runner.

type Runners added in v1.0.0

type Runners struct {
	Client *transport.Client
	Scope  OwnerScope
}

Runners manages the Actions runners of one scope.

func (Runners) Delete added in v1.0.0

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

Delete unregisters a runner.

func (Runners) List added in v1.0.0

func (s Runners) List(ctx context.Context, limit, page int, disabled *bool) (Page[Runner], error)

List lists a page of runners, only the disabled or only the enabled ones when disabled is set.

func (Runners) RegistrationToken added in v1.0.0

func (s Runners) RegistrationToken(ctx context.Context) (RegistrationToken, error)

RegistrationToken returns the token that registers new runners with the scope, which Gitea creates when the scope has none.

func (Runners) SetDisabled added in v1.0.0

func (s Runners) SetDisabled(ctx context.Context, id int64, disabled bool) (Runner, error)

SetDisabled stops a runner from taking jobs, or lets it take them again, and returns it as it is then.

func (Runners) View added in v1.0.0

func (s Runners) View(ctx context.Context, id int64) (Runner, error)

View returns one runner.

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 SetActionSecret added in v1.0.0

type SetActionSecret struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

SetActionSecret names a secret that was just set; Gitea does not return when it was created.

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 Stopwatch added in v1.2.0

type Stopwatch struct {
	Repository  string `json:"repository"`
	IssueNumber int64  `json:"issue_number"`
	IssueTitle  string `json:"issue_title"`
	// Seconds is how long it has run, as Gitea reads it when asked.
	Seconds   int64  `json:"seconds"`
	StartedAt string `json:"started_at"`
}

Stopwatch is a running timer of the account on an issue or pull request.

type Tag added in v1.2.0

type Tag struct {
	Name string `json:"name"`
	// Message is the message of an annotated tag; a lightweight tag has none.
	Message string `json:"message"`
	// Commit is the commit that the tag points to; ID is the SHA of the tag itself, which differs
	// from Commit for an annotated tag.
	Commit     string `json:"commit"`
	ID         string `json:"id"`
	Annotated  bool   `json:"annotated"`
	ZipballURL string `json:"zipball_url"`
	TarballURL string `json:"tarball_url"`
	// Tagger, TaggedAt and the verification are read with gt tag view only, for an annotated tag.
	// Verified and VerificationReason are of the tagged commit: Gitea does not check the tag's signature.
	Tagger             string `json:"tagger"`
	TaggerEmail        string `json:"tagger_email"`
	TaggedAt           string `json:"tagged_at"`
	Verified           bool   `json:"verified"`
	VerificationReason string `json:"verification_reason"`
}

Tag is a tag of a repository.

type TagProtection added in v1.2.0

type TagProtection struct {
	ID          int64  `json:"id"`
	NamePattern string `json:"name_pattern"`
	// Users and Teams may create the matching tags; without them nobody may.
	Users     []string `json:"users"`
	Teams     []string `json:"teams"`
	CreatedAt string   `json:"created_at"`
	UpdatedAt string   `json:"updated_at"`
}

TagProtection is a rule that lets only some users and teams create the tags matching a pattern.

type TagProtectionChanges added in v1.2.0

type TagProtectionChanges struct {
	Users, Teams []string
}

TagProtectionChanges are the parts of a rule to set; nil leaves one as it is and empty clears it.

type TagProtections added in v1.2.0

type TagProtections struct{ Client *transport.Client }

TagProtections manages the tag protection rules of repositories.

func (TagProtections) List added in v1.2.0

func (s TagProtections) List(ctx context.Context, repo string) ([]TagProtection, error)

List lists every rule, in the order that Gitea applies them. Gitea answers all of them at once and ignores page and limit, so a read in pages would never end.

func (TagProtections) OwnerIsOrganization added in v1.2.0

func (s TagProtections) OwnerIsOrganization(ctx context.Context, owner string) (bool, error)

OwnerIsOrganization reports whether owner is an organization, the only owner with teams.

func (TagProtections) Protect added in v1.2.0

func (s TagProtections) Protect(ctx context.Context, repo, pattern string, changes TagProtectionChanges, ids map[string]int64) (item TagProtection, created bool, err error)

Protect adds a rule for pattern, or changes the one in ids. It returns the rule and whether it added one.

func (TagProtections) RuleIDs added in v1.2.0

func (s TagProtections) RuleIDs(ctx context.Context, repo string) (map[string]int64, error)

RuleIDs returns the ID of the rule of each pattern, for a batch of Protect and Unprotect calls to share and keep current.

func (TagProtections) Unprotect added in v1.2.0

func (s TagProtections) Unprotect(ctx context.Context, repo, pattern string, ids map[string]int64) error

Unprotect deletes the rule for pattern in ids.

type Tags added in v1.2.0

type Tags struct{ Client *transport.Client }

Tags manages the tags of repositories.

func (Tags) Create added in v1.2.0

func (s Tags) Create(ctx context.Context, repo, name, target, message string) (Tag, error)

Create creates a tag on target, a branch or commit, which is the default branch when empty. A message makes the tag annotated.

func (Tags) Delete added in v1.2.0

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

Delete deletes a tag.

func (Tags) List added in v1.2.0

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

List lists a page of tags.

func (Tags) View added in v1.2.0

func (s Tags) View(ctx context.Context, repo, name string) (Tag, error)

View returns a tag.

func (Tags) WithTagObject added in v1.2.0

func (s Tags) WithTagObject(ctx context.Context, repo string, item Tag) (Tag, error)

WithTagObject adds who tagged an annotated tag and when, and the signature check of its commit.

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. An owner or admin team has its permission on every unit but the external ones, which it can only read.

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 Templates added in v1.1.0

type Templates struct{ Client *transport.Client }

Templates reads the license and .gitignore templates that Gitea offers for new repositories.

func (Templates) Gitignore added in v1.1.0

func (s Templates) Gitignore(ctx context.Context, name string) (Gitignore, error)

Gitignore returns a .gitignore template by name, matching it without regard to case when Gitea does not know the name as written.

func (Templates) Gitignores added in v1.1.0

func (s Templates) Gitignores(ctx context.Context) ([]GitignoreEntry, error)

Gitignores lists the names of the .gitignore templates.

func (Templates) License added in v1.1.0

func (s Templates) License(ctx context.Context, key string) (License, error)

License returns a license by its key, matching it without regard to case when Gitea does not know the key as written.

func (Templates) Licenses added in v1.1.0

func (s Templates) Licenses(ctx context.Context) ([]LicenseEntry, error)

Licenses lists the licenses.

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, and AssigneeTeam the team such an event asked; RemovedAssignee tells
	// that it unassigned them or withdrew the request.
	Assignee        *string `json:"assignee"`
	AssigneeTeam    *string `json:"assignee_team"`
	RemovedAssignee *bool   `json:"removed_assignee"`
	// DependentIssue is the issue a dependency event added or removed, as OWNER/REPO#NUMBER, or
	// nil for an issue the viewer cannot see.
	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"`
	// Duration is the time, as Gitea words it such as "30 minutes", that an "add_time_manual"
	// or "stop_tracking" event logged or a "delete_time_manual" event deleted.
	Duration *string `json:"duration"`
}

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) Cancel added in v1.2.0

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

Cancel discards the stopwatch on issue n without logging its time.

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.

func (Times) Running added in v1.2.0

func (s Times) Running(ctx context.Context) ([]Stopwatch, error)

Running lists the stopwatches that the account has running, in any repository.

func (Times) RunningOn added in v1.2.0

func (s Times) RunningOn(ctx context.Context, n int64) (Stopwatch, bool)

RunningOn returns the stopwatch that the listing shows on issue n, for its title and elapsed time. Only Gitea's answer to a request about the stopwatch tells whether one runs: the listing can fail on a token that may change the issue, and knows nothing of a missing or renamed repository.

func (Times) Start added in v1.2.0

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

Start starts a stopwatch on issue n.

func (Times) Stop added in v1.2.0

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

Stop stops the stopwatch on issue n and logs the time it ran as tracked time.

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 Webhooks

type Webhooks struct {
	Client *transport.Client
	Scope  OwnerScope
	// 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) Test added in v1.0.0

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

Test asks Gitea to deliver a push event of the default branch's latest commit to a repository webhook. Gitea tests no other webhooks.

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, title string) error

Delete removes the wiki page titled title, as Find returns it.

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) Find added in v1.0.0

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

Find retrieves and decodes the wiki page titled name, for a change to it.

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, also by the page path of its URL.

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