gitea

package
v0.97.8 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package gitea implements the Gitea adapter for the forge capability.

Package gitea implements the software forge capability.

Index

Constants

View Source
const (
	OpGetUser        = "get_user"
	OpGetRepo        = "get_repo"
	OpListIssues     = "list_issues"
	OpGetIssue       = "get_issue"
	OpGetCommitDiff  = "get_commit_diff"
	OpGetFileContent = "get_file_content"
	OpHealth         = "health"
)

Variables

This section is empty.

Functions

func Register

func Register(app string, svc Service) error

Register registers the gitea capability with hub and invoker registry. When svc is nil the provider is not configured and registration is skipped.

Types

type Adapter

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

Adapter implements Service using the Gitea provider client.

func (*Adapter) GetCommitDiff

func (a *Adapter) GetCommitDiff(ctx context.Context, owner, repo, commitID string) (*capability.ForgeCommitDiff, error)

GetCommitDiff returns the diff for a specific commit from the Gitea API.

func (*Adapter) GetFileContent

func (a *Adapter) GetFileContent(ctx context.Context, owner, repo, commitID, filePath string, lineStart, lineCount int) ([]byte, error)

GetFileContent returns file content at a specific commit with line range from the Gitea API.

func (*Adapter) GetIssue

func (a *Adapter) GetIssue(ctx context.Context, owner, repo string, index int64) (*capability.ForgeIssue, error)

GetIssue returns a single issue by owner, repo name, and index from the Gitea API. Because the Gitea SDK does not expose a direct single-issue endpoint, this method fetches issues for the owner and filters by repository name and index.

func (*Adapter) GetRepo

func (a *Adapter) GetRepo(ctx context.Context, owner, repo string) (*capability.ForgeRepo, error)

GetRepo returns a single repository by owner and name from the Gitea API.

func (*Adapter) GetUser

func (a *Adapter) GetUser(ctx context.Context) (*capability.ForgeUser, error)

GetUser returns the authenticated user's profile from the Gitea API.

func (*Adapter) HealthCheck

func (a *Adapter) HealthCheck(ctx context.Context) (bool, error)

HealthCheck reports whether the Gitea backend is reachable by querying the authenticated user.

func (*Adapter) ListIssues

func (*Adapter) SetCursorSecret

func (a *Adapter) SetCursorSecret(secret []byte)

SetCursorSecret sets the cursor signing secret (for testing).

type GiteaWebhook

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

GiteaWebhook implements capability.WebhookConverter for the Gitea provider. It validates HMAC-SHA256 signature and converts Gitea webhook payloads into DataEvent records.

func NewGiteaWebhook

func NewGiteaWebhook() *GiteaWebhook

NewGiteaWebhook creates a GiteaWebhook that reads the HMAC secret from the gitea provider config at verification time.

func (*GiteaWebhook) Convert

func (*GiteaWebhook) Convert(body []byte, headers map[string]string) ([]types.DataEvent, error)

Convert transforms the raw Gitea webhook body into DataEvent records. Event type is determined by the X-Gitea-Event header:

"push"   — parsed as RepoPayload, emitted as forge.push
"issues" — parsed as IssuePayload, emitted as forge.issue.<action>

Unsupported event types are logged and yield no events.

func (*GiteaWebhook) VerifySignature

func (w *GiteaWebhook) VerifySignature(headers map[string]string, body []byte) error

VerifySignature validates the HMAC-SHA256 signature from the X-Gitea-Signature header. The raw body is signed with the configured webhook secret.

func (*GiteaWebhook) WebhookPath

func (*GiteaWebhook) WebhookPath() string

WebhookPath returns the URL path that receives webhook events from Gitea. The full URL is /webhook/provider/gitea/events.

type ListIssuesQuery

type ListIssuesQuery = capability.ForgeListIssuesQuery

ListIssuesQuery wraps pagination and filtering for listing issues.

type Service

type Service interface {
	GetUser(ctx context.Context) (*capability.ForgeUser, error)
	GetRepo(ctx context.Context, owner, repo string) (*capability.ForgeRepo, error)
	ListIssues(ctx context.Context, owner string, q *ListIssuesQuery) (*capability.ListResult[capability.ForgeIssue], error)
	GetIssue(ctx context.Context, owner, repo string, index int64) (*capability.ForgeIssue, error)
	GetCommitDiff(ctx context.Context, owner, repo, commitID string) (*capability.ForgeCommitDiff, error)
	GetFileContent(ctx context.Context, owner, repo, commitID, filePath string, lineStart, lineCount int) ([]byte, error)
	HealthCheck(ctx context.Context) (bool, error)
}

Service defines the forge capability contract.

func New

func New() Service

New creates an Adapter using the default provider client. Returns nil when the provider is not configured or unavailable.

func NewWithClient

func NewWithClient(c client) Service

NewWithClient creates an Adapter with a specific client, useful for testing.

Jump to

Keyboard shortcuts

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