github

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package github implements forge.Forge over the GitHub API, authenticated as the GitHub App installation.

Index

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

func New(client *gh.Client, app *ghapp.App, installationID int64) *Forge

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

func (f *Forge) ParseWebhook(r *http.Request) (forge.Event, error)

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.

Jump to

Keyboard shortcuts

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