github

package
v0.93.0 Latest Latest
Warning

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

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

Documentation

Overview

Package github implements the GitHub adapter for the github capability.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() githubsvc.Service

New creates an Adapter using the default provider client.

func NewWithClient

func NewWithClient(c client) githubsvc.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 githubsvc.Service using the GitHub 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 GitHub 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 GitHub 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. Lists 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 GitHub API.

func (*Adapter) GetUser

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

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

func (*Adapter) GetUserByLogin

func (a *Adapter) GetUserByLogin(ctx context.Context, login string) (*ability.ForgeUser, error)

GetUserByLogin returns a GitHub user's profile by login name from the GitHub API.

func (*Adapter) ListIssues

ListIssues returns a paginated list of issues for the given owner from the GitHub API.

func (*Adapter) ListNotifications

ListNotifications returns the authenticated user's notifications from the GitHub API.

func (*Adapter) ListReleases

func (a *Adapter) ListReleases(ctx context.Context, owner, repo string, q *githubsvc.PageQuery) (*ability.ListResult[ability.Release], error)

ListReleases returns releases for a repository from the GitHub API.

func (*Adapter) SetCursorSecret

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

SetCursorSecret sets the cursor signing secret (for testing).

type GithubWebhook

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

GithubWebhook implements ability.WebhookConverter for the GitHub provider. It validates HMAC-SHA256 signature and converts GitHub webhook payloads into DataEvent records.

func NewGithubWebhook

func NewGithubWebhook() *GithubWebhook

NewGithubWebhook creates a GithubWebhook that reads the HMAC secret from the github provider config at verification time.

func (*GithubWebhook) Convert

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

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

"push"   — emitted as forge.push
"issues" — emitted as forge.issue.<action>

Unsupported event types and actions are logged and yield no events.

func (*GithubWebhook) VerifySignature

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

VerifySignature validates the HMAC-SHA256 signature from the X-Hub-Signature-256 header. GitHub signs the raw body with the configured webhook secret using SHA-256, and sends it as "sha256=<hex digest>".

func (*GithubWebhook) WebhookPath

func (*GithubWebhook) WebhookPath() string

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

Jump to

Keyboard shortcuts

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