Documentation
¶
Overview ¶
Package github implements forge.Forge over the GitHub API, authenticated as the GitHub App installation.
Index ¶
- type Forge
- func (f *Forge) GetPullRequest(ctx context.Context, owner, repo string, number int) (*forge.PullRequest, error)
- func (f *Forge) ListChangedFiles(ctx context.Context, owner, repo string, number int) ([]forge.ChangedFile, error)
- func (f *Forge) ListOpenPullRequests(ctx context.Context, owner, repo string) ([]forge.PullRequest, error)
- func (f *Forge) ParseWebhook(r *http.Request) (forge.Event, error)
- func (f *Forge) UpsertComment(ctx context.Context, owner, repo string, number int, body string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Forge ¶
type Forge struct {
// contains filtered or unexported fields
}
Forge is the GitHub forge: pull requests and comments through client, and webhook deliveries signed with app's secret from the installation installationID.
func New ¶
New returns the GitHub forge over client. Webhook deliveries are validated with app and accepted only from the installation installationID.
func (*Forge) GetPullRequest ¶
func (f *Forge) GetPullRequest(ctx context.Context, owner, repo string, number int) (*forge.PullRequest, error)
GetPullRequest reads owner/repo#number. Lookup failures (including 404 and 403) are returned as errors.
func (*Forge) ListChangedFiles ¶
func (f *Forge) ListChangedFiles(ctx context.Context, owner, repo string, number int) ([]forge.ChangedFile, error)
ListChangedFiles lists the files owner/repo#number changes, reading every page (100 files each). GitHub lists at most forge.MaxListedFiles. A failure on any page is returned as an error.
func (*Forge) ListOpenPullRequests ¶
func (f *Forge) ListOpenPullRequests(ctx context.Context, owner, repo string) ([]forge.PullRequest, error)
ListOpenPullRequests lists the open pull requests of owner/repo, reading every page (100 each). Their ChangedFiles is 0: a listed pull request has no changed_files. A failure on any page is returned as an error.
func (*Forge) ParseWebhook ¶
ParseWebhook validates the delivery's signature, parses its payload, checks that it comes from the allowed installation and returns it as a forge.Event. A rejected signature is logged and returns forge.ErrUnverified with a zero Event. Every later outcome has the Event's Name: a payload that can't be parsed is logged and its error returned; a delivery from another installation, or without one, is logged and returns forge.ErrForbidden (ping is exempt because it carries no installation). ping, installation and installation_repositories deliveries, and the event types badil does not handle, are logged here and returned with forge.KindOther. The X-Github-Event value is logged as the event attribute.
func (*Forge) UpsertComment ¶
func (f *Forge) UpsertComment(ctx context.Context, owner, repo string, number int, body string) error
UpsertComment posts body as badil's comment on owner/repo#number, prefixed with prCommentMarker: the existing marked comment, searched across every page, is updated, or a new one is created.