Documentation
¶
Overview ¶
Package prmerge is the engine behind `devctl pr merge`: the refusals that come before any wait, the wait of pkg/prwait, then the merge.
A merge is refused before the first poll for a pull request no wait can turn green (draft, closed, conflicting, behind a strict base; exit 3), for a pull request another human opened (exit 5: bots, GitHub Apps and the caller are fine) and in a repository whose team-file entry opts out of agent merges (exit 5, naming the field). Green lands through the merge API as a squash or a rebase with the judged head as the expected head, then the branch goes through the refs API. A base with a merge queue is enqueued instead and the pull request waited for. No protection setting, ruleset or enforce_admins is read to be changed, or written.
Index ¶
Constants ¶
const AgentMergeField = "agentMerge"
AgentMergeField is the team-file entry field that opts a repository out of agent merges.
Variables ¶
This section is empty.
Functions ¶
func IsExecution ¶
IsExecution asserts executionError: GitHub did not do what it accepted to do within the bound (an update-branch that produced no new head).
func IsInvalidConfig ¶
IsInvalidConfig asserts invalidConfigError.
Types ¶
type Config ¶
type Config struct {
// Wait is the wait engine's configuration; its GitHub client, clock,
// progress writer and timeout are the merge's too. Required.
Wait prwait.Config
// Method is squash or rebase; empty is squash.
Method githubclient.MergeMethod
// UpdateBranch: a head behind a strict base is updated from the base
// and the new head waited for, instead of exit 3.
UpdateBranch bool
// Login is the account the token acts as, for the author check; empty
// reads it from GET /user.
Login string
// Policy is the repository's opt-out; nil is [TeamFilePolicy] on the
// GitHub client.
Policy Policy
}
Config configures a Merger.
type Merger ¶
type Merger struct {
// contains filtered or unexported fields
}
Merger runs merges.
type Policy ¶
Policy is the repository's say on agent merges: an empty refusal allows the merge, a non-empty one is the sentence exit 5 carries.
func TeamFilePolicy ¶
TeamFilePolicy reads the repository's entry the way pkg/reposetup reads one: the team files of giantswarm/github at main, the entry named after the repository. An entry with `agentMerge: false` refuses; an entry without the field, a repository no team file declares and a repository outside the organisation the team files declare are not opted out. Team files the token cannot read are an error: the opt-out is not guessed.
type Result ¶
type Result struct {
prwait.Result
// MergeCommitSHA is the commit the merge produced; empty when nothing
// merged.
MergeCommitSHA string `json:"mergeCommitSha"`
// Method is squash or rebase.
Method string `json:"method"`
// BranchDeleted: the head branch was deleted after the merge (or was
// gone already). False for a head in a fork, which is left alone.
BranchDeleted bool `json:"branchDeleted"`
// Enqueued: the base has a merge queue and the pull request went
// through it.
Enqueued bool `json:"enqueued"`
}
Result is the command's part of the document: the wait's fields and the merge's.