githubapi

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ApprovalResetComment = "Approval has been reset since this PR was reopened."

ApprovalResetComment is posted when a PR is reopened to signal that previous approvals are void. countApprovals uses it as a marker to discard approvals granted before the reopen.

Variables

View Source
var Commands = func() []CommandDef {
	table := buildDispatchTable(1)
	defs := make([]CommandDef, len(table))
	for i, ch := range table {
		defs[i] = ch.def
	}
	return defs
}()

Commands exposes the command definitions for doc generation.

View Source
var EventPluginLabels = []LabelDef{
	{Name: "lgtm", Meaning: "PR has been approved."},
	{Name: "do-not-merge", Meaning: "PR is not ready to merge."},
}

EventPluginLabels documents the labels used by the event plugin.

View Source
var PREvents = []PREventDef{
	{
		Action:   "opened",
		Behavior: "Adds `do-not-merge` label; creates LGTM check run with `neutral` conclusion.",
	},
	{
		Action:   "reopened",
		Behavior: "Adds `do-not-merge`, removes `lgtm`, posts an approval-reset comment, and creates an LGTM check run with `neutral` conclusion.",
	},
}

PREvents documents the pull_request webhook actions handled by the event plugin.

Functions

func NewPREventHandler added in v0.4.0

func NewPREventHandler(minApprovals int) func(*github.PullRequestEvent, *github.Client, *slog.Logger)

NewPREventHandler returns a pull_request event handler configured with the given minimum approvals.

func NewProcessComment added in v0.4.0

func NewProcessComment(minApprovals int) func(*github.IssueCommentEvent, *github.Client, *slog.Logger)

NewProcessComment returns a ProcessComment function configured with the given minimum approvals.

func ProcessComment

func ProcessComment(event *github.IssueCommentEvent, client *github.Client, logger *slog.Logger)

ProcessComment dispatches slash commands with a default of 1 required approval.

func RegisterEventHandlers

func RegisterEventHandlers(
	r *gin.Engine,
	client *github.Client,
	logger *slog.Logger,
	processComment func(*github.IssueCommentEvent, *github.Client, *slog.Logger),
	handlePR func(*github.PullRequestEvent, *github.Client, *slog.Logger),
) func(string, []byte)

Types

type CommandDef added in v0.3.0

type CommandDef struct {
	// Triggers are the slash-command prefixes that activate this command.
	Triggers    []string
	Description string
	// Usage shows the full invocation syntax.
	Usage string
}

CommandDef describes a slash command handled by the event plugin.

type LabelDef added in v0.3.0

type LabelDef struct {
	Name    string
	Meaning string
}

LabelDef documents a GitHub label used by the event plugin.

type PREventDef added in v0.3.0

type PREventDef struct {
	Action   string
	Behavior string
}

PREventDef documents a pull_request webhook action handled by the event plugin.

type ProwGitHubClient

type ProwGitHubClient interface {
	GetClient() *github.Client
	CreateCheckRun(ctx context.Context, owner, repo string, opt github.CreateCheckRunOptions) (*github.CheckRun, *github.Response, error)
}

ProwGitHubClient is the interface consumed by callers that need a GitHub client.

type ProwLiteGitHubClient

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

ProwLiteGitHubClient wraps a GitHub client authenticated as a GitHub App installation.

func NewGithubClient

func NewGithubClient(logger *slog.Logger) (*ProwLiteGitHubClient, error)

func (*ProwLiteGitHubClient) CreateCheckRun

func (*ProwLiteGitHubClient) GetClient

func (g *ProwLiteGitHubClient) GetClient() *github.Client

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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