Documentation
¶
Overview ¶
Package gitea implements the Gitea adapter for the forge capability.
Package gitea implements the software forge capability.
Index ¶
- Constants
- func Register(app string, svc Service) error
- type Adapter
- func (a *Adapter) GetCommitDiff(ctx context.Context, owner, repo, commitID string) (*capability.ForgeCommitDiff, error)
- func (a *Adapter) GetFileContent(ctx context.Context, owner, repo, commitID, filePath string, ...) ([]byte, error)
- func (a *Adapter) GetIssue(ctx context.Context, owner, repo string, index int64) (*capability.ForgeIssue, error)
- func (a *Adapter) GetRepo(ctx context.Context, owner, repo string) (*capability.ForgeRepo, error)
- func (a *Adapter) GetUser(ctx context.Context) (*capability.ForgeUser, error)
- func (a *Adapter) HealthCheck(ctx context.Context) (bool, error)
- func (a *Adapter) ListIssues(ctx context.Context, owner string, q *ListIssuesQuery) (*capability.ListResult[capability.ForgeIssue], error)
- func (a *Adapter) SetCursorSecret(secret []byte)
- type GiteaWebhook
- type ListIssuesQuery
- type Service
Constants ¶
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 ¶
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) HealthCheck ¶
HealthCheck reports whether the Gitea backend is reachable by querying the authenticated user.
func (*Adapter) ListIssues ¶
func (a *Adapter) ListIssues(ctx context.Context, owner string, q *ListIssuesQuery) (*capability.ListResult[capability.ForgeIssue], error)
func (*Adapter) SetCursorSecret ¶
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 ¶
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.