gitea

package
v0.92.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package gitea implements the Gitea adapter for the forge capability.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() forge.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) forge.Service

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

Types

type Adapter

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

Adapter implements forge.Service using the Gitea provider client.

func (*Adapter) GetCommitDiff

func (a *Adapter) GetCommitDiff(ctx context.Context, owner, repo, commitID string) (*ability.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) (*ability.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) (*ability.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) (*ability.ForgeUser, error)

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

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 ability.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.

Jump to

Keyboard shortcuts

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