Documentation
¶
Overview ¶
Package forge is the port for pull-request operations. It is vendor neutral: GitHub via gh, GitHub via the REST API and GitLab are adapters.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckSummary ¶ added in v0.2.0
type CheckSummary struct {
// Failing checks finished without passing (failed, errored, timed
// out, cancelled, needing action).
Failing []string `json:"failing,omitempty"`
// Pending checks are queued, waiting or still running.
Pending []string `json:"pending,omitempty"`
}
CheckSummary is where the checks on a pull request's head commit stand, by name. Checks that passed, or were skipped or neutral, aren't listed.
func (CheckSummary) Clean ¶ added in v0.2.0
func (c CheckSummary) Clean() bool
Clean reports whether nothing is failing or still running.
type Forge ¶
type Forge interface {
// ListPRs returns every pull request whose head is a branch of this
// repository, in one call.
ListPRs(ctx context.Context, repo git.Repo) ([]PullRequest, error)
CreatePR(ctx context.Context, repo git.Repo, in CreatePR) (PullRequest, error)
UpdatePR(ctx context.Context, repo git.Repo, number int, in UpdatePR) error
// MergeStack merges pull request number together with every open pull
// request below it in its stack, all or nothing, and waits until the
// forge reports the result (or has queued it). A refusal, such as a
// draft in the way or a failed check, comes back as a *stack.Error.
MergeStack(ctx context.Context, repo git.Repo, number int, method MergeMethod) (MergeOutcome, error)
// Checks reports the checks on the current head commit of each pull
// request in numbers, asking the forge about all of them together
// rather than one at a time. A pull request with no checks at all may
// be missing from the map.
Checks(ctx context.Context, repo git.Repo, numbers []int) (map[int]CheckSummary, error)
// CreateStack groups pull requests into a stack on the forge, bottom
// to top. GitHub needs at least two, none of them already in a stack,
// each based on the head of the one before. A refusal comes back as a
// *stack.Error of kind api_failure carrying the forge's message.
CreateStack(ctx context.Context, repo git.Repo, numbers []int) (StackRef, error)
// PullRequestURL is the web address of pull request number, worked out
// from local configuration only (never the network), so output can
// link a PR the forge hasn't been asked about. "" when it can't tell.
PullRequestURL(ctx context.Context, repo git.Repo, number int) (string, error)
}
Forge performs pull-request operations for the repository's remote.
type MergeMethod ¶ added in v0.1.5
type MergeMethod string
MergeMethod says how a pull request lands on its base.
const ( // MergeDefault leaves the choice to the repository's settings. MergeDefault MergeMethod = "" MergeMerge MergeMethod = "merge" MergeSquash MergeMethod = "squash" MergeRebase MergeMethod = "rebase" )
type MergeOutcome ¶ added in v0.1.5
type MergeOutcome struct {
Status MergeStatus
// SHA is the merge commit on the base branch; empty when enqueued.
SHA string
// Message is the forge's own description of the outcome, if any.
Message string
}
MergeOutcome reports a finished stack merge.
type MergeStatus ¶ added in v0.1.5
type MergeStatus string
MergeStatus is where a stack merge ended up.
const ( // MergeMerged: the pull requests are on the base branch. MergeMerged MergeStatus = "merged" // MergeEnqueued: the base branch uses a merge queue and the pull // requests are in it; they land when the queue gets to them. MergeEnqueued MergeStatus = "enqueued" )
type PullRequest ¶
type PullRequest struct {
Number int `json:"number"`
URL string `json:"url"`
Title string `json:"title"`
Body string `json:"body,omitempty"`
State State `json:"state"`
Head string `json:"head"`
Base string `json:"base"`
// HeadSHA is the head commit the forge last saw for this PR.
HeadSHA string `json:"headSha,omitempty"`
// MergeCommit is the commit the PR was merged as, "" unless merged.
MergeCommit string `json:"mergeCommit,omitempty"`
UpdatedAt time.Time `json:"updatedAt"`
}
PullRequest is a forge-neutral pull request.
type StackRef ¶ added in v0.3.0
type StackRef struct {
// ID is the forge's identifier for the stack.
ID string
// Number is the stack's number within the repository.
Number int
}
StackRef names a stack of pull requests on the forge.