landing

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 45 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 landing is the landing of a branch whose preflight passed: the gate (a preflight receipt naming the branch's head), a plain push of the branch to origin, and the merge the repository's own rules allow. `abcd land` is its front door for any branch; the implement loop's land stage (internal/core/implement/loop) shares its lane-free primitives, so the receipt lookup, the bounded runner, the forge client's invocation and the ruleset mirror's reading are spelled once.

The package is transport-agnostic: it never writes to stdout. What a step did comes back as a Result for the front door to render.

Index

Constants

View Source
const (
	KeyPush    = "land.push"
	KeyEnqueue = "land.enqueue"
)

The landing's configuration keys, in .abcd/config.json and ~/.abcd.noindex/config.json, each a bool whose bundled default is true.

View Source
const (
	KeyFacilitatorMode = "facilitator.mode"
	ModeHuman          = "human"
	ModeAuto           = "auto"
)

KeyFacilitatorMode declares who merges: the repository's technical facilitator is a person (ModeHuman, the bundled default) or abcd (ModeAuto). It says nothing about abcd mode's facilitator state, which is whose answer the loop is waiting on right now.

View Source
const (
	// MaxDeltaFiles is how many files a delta may touch, counted once each.
	MaxDeltaFiles = 3
	// MaxDeltaLines is how many lines a delta may change, added and removed
	// together, summed over the branch's own commits.
	MaxDeltaLines = 30
)

The bound on a delta: the most a branch's own commits may change since the base head and still rest on its full pair. It is drawn around what the records show a delta is for, a one-sentence fix to a record.

View Source
const (
	RoleMaintainer  = "maintainer"
	RoleContributor = "contributor"
	RoleUnverified  = "unverified"
)

The author's role on the repository, as the merge gate reads it.

View Source
const (
	// StatusDone: the step did its act.
	StatusDone = "done"
	// StatusSkipped: the step's act was already done (a receipt names HEAD).
	StatusSkipped = "skipped"
	// StatusOff: a configuration key or a flag turned the act off.
	StatusOff = "off"
	// StatusStopped: the step cannot act yet; its note says what to do, and
	// running abcd land again resumes it.
	StatusStopped = "stopped"
	// StatusLeft: the act is a person's, and land leaves it to them.
	StatusLeft = "left"
	// StatusLanded: the branch's head is already on the default branch.
	StatusLanded = "landed"
)

The statuses a step reports.

View Source
const (
	// ForgeTimeout is the longest one forge client call may run.
	ForgeTimeout = 2 * time.Minute
	// MaxOutput bounds what a forge client call may write to stdout.
	MaxOutput = 1 << 20
)

Bounds on what the landing runs.

View Source
const ApprovalsRelDir = TierRelDir + "/approvals"

ApprovalsRelDir holds the technical facilitator's recorded approvals, one file per commit named by its full object name, beside the review receipts. The forge refuses an author's approval of their own pull request, and the facilitator authors most of the pull requests abcd opens, so their approval is also an act abcd records (`abcd land --approve`), run by a person; the shell guard refuses it to an agent.

View Source
const ArmingsQuery = `` /* 299-byte string literal not displayed */

ArmingsQuery lists the open pull requests from one head branch, with what says whether each is armed (autoMergeRequest) or queued (isInMergeQueue), who did it, and the viewer's login: the forge clears autoMergeRequest as a pull request enters the queue, so both are read. A branch's name can be shared with forks, so the listing says whether more lie past the page, and a listing that does is no answer. The committed pre-push hook asks the same question.

View Source
const FetchedReadTimeout = 15 * time.Second

FetchedReadTimeout bounds ReadFetchedFacilitator as a whole: the shell guard asks it inside a host's hook, which may give up on a slow hook and run the command anyway, so a slow origin must end the read first, as human.

View Source
const MaxReviewReturnBytes = 1 << 20

MaxReviewReturnBytes bounds one review return read for a receipt.

View Source
const PRStateQuery = `` /* 520-byte string literal not displayed */

PRStateQuery is the forge's GraphQL query for a pull request's way to the merge: `gh pr view --json` has no merge-queue field (gh 2.100.0 refuses isInMergeQueue), so the state is read through the forge's API instead.

It also reads the pull request's node id (what the dequeue takes), the viewer's login (whose arming is land's own), who queued it, the review decision, when and by whom the arming was made, and the head's checks with whether this pull request requires each (isRequired takes the pull request's number; with neither it nor an id the forge refuses the field). Every field is pinned in ghcontract, and testdata/ holds the forge's answers to this query.

The checks are read a page at the forge's maximum (it refuses first:101, "exceeds the `first` limit of 100 records"), with whether more follow, and each with the time it finished (completedAt; a status's createdAt), which times the toggle's grace.

View Source
const PreflightBound = preflightGateWait + preflightRaceGateWait + preflightRunBound

PreflightBound is gateTimeout's value, for a reader outside landing.

View Source
const ReceiptsRelDir = TierRelDir + "/preflight-receipts"

ReceiptsRelDir is where the preflight mints its receipts, one file named by the full commit id, in any worktree of the repository (scripts/preflight-receipt.sh). A receipt is a convenience check, not a security boundary: CI re-runs every gate on the pushed commit and is the authority, and the receipt says only that a preflight passed on a tree that matched the commit.

View Source
const Remote = "origin"

Remote is the one remote a branch lands through.

View Source
const ReviewReceiptsRelDir = TierRelDir + "/review-receipts"

ReviewReceiptsRelDir holds one review receipt per commit, named by its full object name, beside the preflight receipts (spc-2610161609350616 step 3). The merge gate reads one in auto mode, from any worktree of the repository but one that is a drive lane's or lies inside one (insideDriveLane).

View Source
const RulesetsRelDir = ".abcd/work/rulesets"

RulesetsRelDir is the committed mirror of the default branch's rulesets.

View Source
const TierRelDir = ".abcd/.work.local"

TierRelDir is the local-ephemeral tier of a checkout, repo-relative and slash-separated: gitignored, per worktree.

Variables

View Source
var ErrDriveLaneRecord = errors.New("the merge gate never counts a review receipt or a recorded approval in a drive lane's worktree")

ErrDriveLaneRecord refuses a review receipt or a recorded approval written in a drive lane's worktree, which the merge gate would never count.

View Source
var ErrModeUnreadable = errors.New("facilitator.mode cannot be read")

ErrModeUnreadable wraps a facilitator.mode the gate could not read, whose text a front door masks before printing: nothing is armed.

View Source
var ErrNoDefaultBranch = errors.New("the repository has no default branch to read " + KeyFacilitatorMode + " at")

ErrNoDefaultBranch is ReadDefaultFacilitator's answer for a repository with no default branch to read facilitator.mode at: one with no commit yet, say. It is not a refusal of anything a file declares, so a caller that only shows the mode (the status line) may stay quiet over it.

View Source
var ErrNoForgeClient = errors.New("the forge client `gh` is not installed")

ErrNoForgeClient is GH's answer when the forge client is not installed.

View Source
var ErrOutputCap = errors.New("the forge client's output bound")

ErrOutputCap marks a forge client's answer refused for passing MaxOutput.

View Source
var MergeMethods = map[string]string{"MERGE": "--merge", "SQUASH": "--squash", "REBASE": "--rebase"}

MergeMethods maps a merge queue's method to the forge client's flag.

Functions

func ApprovalRecord added in v0.17.0

func ApprovalRecord(ctx context.Context, repoRoot, sha string, wts []gitutil.Worktree) (string, error)

ApprovalRecord is approvalRecord for a reader of past landings (internal/core/landings), bound to ctx: the technical facilitator's recorded approval of sha in any of wts, by findReceipt's rule (a regular file, never a symlink, and never one git tracks). wts nil lists the worktrees git knows for the repository at repoRoot, as findReceipt does; a reader asking about many commits lists them once and passes them in. Either way one in a drive lane's worktree is passed over, and every one is when repoRoot is a drive lane's worktree or lies inside one (insideDriveLane).

func AutoAt added in v0.16.2

func AutoAt(r layered.Roots, repoRoot, tip, name string) bool

AutoAt reports whether the facilitator mode the merge gate reads at tip is auto.

func AutonomousMerging added in v0.16.0

func AutonomousMerging(ctx context.Context, root string) (bool, string)

AutonomousMerging is the status line's merging element, read: it reports whether the repository's facilitator.mode is auto, read through the merge gate's own resolver (readDefaultFacilitatorContext): the default branch's committed .abcd/config.json and the machine layer, never the working tree's copy, so an auto written only in the working tree changes neither the row nor the gate. The row reads the default branch as last fetched while the gate fetches first, so after the mode changes on origin the two can differ until the next fetch. Its git questions are bounded by ctx, the row's git share, and ask the network nothing. A repository with no default branch yet says nothing and notes nothing: there is nothing to merge into. Any other failure drops the element and returns the note saying why, masked, for the front door's stderr.

It lives here rather than in core/statusline because statusline cannot import this package: landing reaches ahoy (through embargo, capture and site), and ahoy reads statusline, so the import would close a cycle. The front door hands it to statusline as statusline.MergingMode.

func CommittedMode added in v0.17.0

func CommittedMode(ctx context.Context, repoRoot, commit string) (mode string, found bool, err error)

CommittedMode is facilitator.mode as .abcd/config.json held it at commit, a full object name the repository at repoRoot holds, read from its object store as readFacilitatorAt reads the default branch's tip (bounded, a regular file only) and judged by checkMode: the repository layer alone, never the machine layer, since a reader of a past commit cannot read the machine as it was then. found says whether the commit holds the file at all; a file that sets no mode is human, the bundled default, and so is a commit without one. Its git questions are bound to ctx and read the commit's trees and the file's blob as stored (layered.Roots.RepoAtAsStored: no replace ref stands one in for another), as the landings reader, its one caller, reads the rest of history; the merge gate's own read (readFacilitatorAt) is unchanged. The error is the reader's raw text, for the caller to mask.

func DriveLaneWorktreeForTest added in v0.17.0

func DriveLaneWorktreeForTest(path string) bool

DriveLaneWorktreeForTest is driveLaneWorktree, for the implement loop's parity test, which holds the loop's own lane check to the gate's.

func FetchDefault

func FetchDefault(git GitFunc, dir, def string) (string, error)

FetchDefault fetches the default branch def from origin into its remote-tracking ref through git, and returns the ref. A refused fetch is a *FetchError.

func GH

func GH(dir string, args ...string) (string, error)

GH runs the forge client the repository already uses (`gh`) with args from dir, bounded by ForgeTimeout and MaxOutput, with no prompt and no update notice. Its environment is scrubbed as the networked git runner's is (gitutil.ScrubbedEnv): an inherited GIT_DIR or an injected GIT_CONFIG_* cannot aim the client's own git reads at another repository. Every value that comes from a record or a branch rides in its flag's own argument (--flag=value) at the caller, so none can be read as a flag of its own.

func GHAnswerContext added in v0.17.0

func GHAnswerContext(parent context.Context, dir string, args ...string) (string, error)

GHAnswerContext is GHContext that keeps the client's answer beside the error of a failed exit (runCappedAnswer): the forge client exits non-zero on a GraphQL answer carrying errors, and a reader that judges each error by the part of the answer it names reads that answer whole.

func GHContext added in v0.16.0

func GHContext(parent context.Context, dir string, args ...string) (string, error)

GHContext is GH bound to ctx as well as to ForgeTimeout: the client is killed at whichever ends first, and its output is read to EOF before it is waited for (procgroup.RunToEOF), so a client that answered is read whole however late its output closes, and a process it started that still holds that output open holds the call no further than the bound: a caller's own deadline (the away mode's stop check, which lists the forge under ten seconds) holds.

func Landed

func Landed(git GitFunc, dir, def, sha string) (tracking string, on bool, err error)

Landed fetches the default branch def and reports whether sha is on it as origin holds it (an ancestor of, or equal to, its tip): the one ancestry check by which a landing proves a head merged, the implement loop's and `abcd land`'s. A squash or rebase merge leaves no such ancestry; mergedAt is the forge's half of the proof for it. A refused fetch is a *FetchError; any other error is git unable to answer, which is not a no.

func NormalizeLineBreaks added in v0.17.0

func NormalizeLineBreaks(text string) string

NormalizeLineBreaks ends every line of text with a newline, whichever way it ended, so a text is read for a verdict by the lines ReadVerdict reads.

func ReadVerdict added in v0.17.0

func ReadVerdict(text, subject string) (string, error)

ReadVerdict reads the verdict a return states of subject, the full name of what it judges: the head of a commit, or a draft's digest. It is the one rule every reader of a reviewer's return asks, and it holds a return to this:

  • exactly one line opens a verdict (verdictLines), counted wherever it stands, fenced or not, and that line is the exact Verdict heading;
  • the first non-blank line under it begins with a verdict word (list marker and emphasis stripped, its words joined by a space, a hyphen or an underscore, in capitals) that ends the line or is followed by a separator;
  • subject is named in full, on that line or on a `Head: <name>` line directly under the heading, and the first full name after the verdict word on its line, where the line holds one, is subject: what follows that name is not read, and no other name stands ahead of it or on the `Head:` line. A run of hex holding a digit is another name, unless it is the number of a record id, all digits and no more than twenty of them (recordid.IDNumberAt), as the digits of iss-2611060835372141 are.

subject is named in full because a head's name is a hash over the text it reviews, which therefore cannot hold it, and only the full name is. It returns the word as knownVerdicts spells it, and an error for anything short of the above.

func Receipt

func Receipt(repoRoot, sha string) (string, error)

Receipt finds the preflight receipt for sha in any worktree git lists for the repository at repoRoot, as the pre-push hook's check does, and returns its path, or "" when none names sha. A receipt must be a regular file, never a symlink.

It stays on the deadline-free finder rather than calling ReceiptContext with a Background context, which the hook git audit would count as a new deadline-free call (dcn-2611101237202451).

func ReceiptContext added in v0.17.0

func ReceiptContext(ctx context.Context, repoRoot, sha string) (string, error)

ReceiptContext is Receipt with its git calls (the worktree listing and each receipt's tracked check) bound to ctx, for a reader on a deadline, the away mode's stop check among them: a ctx already ended starts no git and refuses with its own error, and one that ends while git runs kills it.

func RecordApproval added in v0.16.0

func RecordApproval(repoRoot, sha string) (string, error)

RecordApproval records the technical facilitator's approval of the commit sha, the full object name of a commit the repository at repoRoot holds, in that checkout's local tier, and returns the record's path. It is the act `abcd land --approve` runs for a person; nothing in abcd runs it on its own, and the shell guard refuses it to an agent. A checkout that is a drive lane's worktree or lies inside one (insideDriveLane) is refused (ErrDriveLaneRecord), since the gate never counts an approval there.

func RecordDeltaReview added in v0.16.2

func RecordDeltaReview(repoRoot, head, base string, returns []ReviewReturn) (string, error)

RecordDeltaReview writes the review receipt for the commit head, resting on the full pair base has: a review pair as RecordReview takes one, each return also stating that it read base..head, over a delta that stands (judgeDelta). Anything short of that is refused and nothing is written. A delta never replaces a full pair already recorded for head. A checkout that is a drive lane's worktree or lies inside one is refused (ErrDriveLaneRecord), as RecordReview refuses it.

func RecordMergeGate added in v0.17.0

func RecordMergeGate(root, site, pr, head string, d MergeDecision) string

RecordMergeGate keeps d, the merge gate's answer about pull request pr at head, for the spot-check (spc-2610301925429250 step 1), when the answer is one abcd took as the facilitator alone (takenAlone): read from the fields the gate set as it decided, never from the words of its reason. The record (spotcheck.Decision of kind merge-gate) names site, the pull request and its head, the answer as the gate gave it (whether it armed, the method, the reason and whether it rests on an answer the gate could not read) and the three facts it was taken on: the mode, whether the author can write to the repository and whether a person's approval counted. Nothing else is read for it: no forge, no mode, no receipt. It is committed on the store's local copy and reaches no network, and the gate asked again over the same head with the same answer keeps the one record. A record that cannot be written changes nothing: the reason is returned for the caller to add to the decision's Why, "" when the record is kept or not taken.

func RecordReview added in v0.16.0

func RecordReview(repoRoot, sha string, returns []ReviewReturn) (string, error)

RecordReview writes the review receipt for the commit sha in the local tier of the checkout at repoRoot, once the review pair's returns pass the stop rule: at least two returns, no two the same text, each stating the commit on its first line (statesHead) and each stating a passing verdict that names the commit (ReadVerdict). Anything short of that is refused, naming the return, and nothing is written. sha must be the full object name of a commit the repository holds. A return that states a delta is refused: it is a delta's (RecordDeltaReview). A checkout that is a drive lane's worktree or lies inside one (insideDriveLane) is refused (ErrDriveLaneRecord), since the gate never counts a receipt there.

func RecordsCommitShape added in v0.16.2

func RecordsCommitShape(repoRoot, base, head string, issues []string) (string, error)

RecordsCommitShape says why the commits from base to head are not what a landing's records commit holds, "" when they are: every path a plain-text markdown file of mode 100644, none under a record folder spelled in another case, and no issue's record moved but those named in issues, what the full round was told of. A record changed where it stands is not bounded: a landing's own relink touches other records, and a pair reads it. History is read as stored. The error is git's, when it could not say.

func ReleaseHoldForTest added in v0.15.1

func ReleaseHoldForTest(root, home string) (string, error)

ReleaseHoldForTest is releaseHold, for the implement loop's parity test, which reads it from outside this package.

func RemoteTip added in v0.16.2

func RemoteTip(git GitFunc, dir, branch string) (string, error)

RemoteTip is the commit origin's branch is at, asked of origin itself, or "" when origin has no such branch.

func StatesFullPair added in v0.16.2

func StatesFullPair(text, head string) error

StatesFullPair reports why a build-loop reviewer's return does not state, on its first line, that it read head as a whole, by the rule a receipt reads it.

func StillArmed added in v0.16.2

func StillArmed(forge ForgeCall, branch string, number int) (bool, error)

StillArmed is the read-back after a withdrawal, for a caller that lets gh name the checkout's repository: whether the forge still reports pull request number from branch armed or queued. gh exits 0 on some failures, so the forge's word is asked, not the call's.

func WithdrawArming added in v0.16.2

func WithdrawArming(forge ForgeCall, n, id string, auto, queued bool) error

WithdrawArming takes pull request n, node id id, off the forge's merge path: auto-merge off first, so the forge cannot queue it again between the two calls, then out of the queue. `gh pr merge --disable-auto` does not dequeue, so the queue entry takes the forge's own mutation. A dequeue that fails after auto-merge came off says so.

Types

type Facilitator added in v0.16.0

type Facilitator struct {
	Key    string `json:"key"`
	Mode   string `json:"mode"`
	Layer  string `json:"layer"`
	Origin string `json:"origin"`
	// HomeRefused says a refused home decided the mode (human), so Origin is
	// the reason, not a file.
	HomeRefused bool `json:"home_refused,omitempty"`
}

Facilitator is facilitator.mode as resolved: the mode, and the layer and origin that decided it. Layer is "bundled" (Origin "bundled") when no layer declares the key; otherwise Origin names the file that set it (".abcd/config.json", or the machine file in its tilde form), or, for a refused home, why the machine layer could not be read.

func ReadDefaultFacilitator added in v0.16.0

func ReadDefaultFacilitator(cwd string) (Facilitator, error)

ReadDefaultFacilitator resolves facilitator.mode for the repository holding cwd as the merge gate does (readFacilitatorAt), at the tip of the default branch git tracks for it (gitutil.DefaultRef), with the machine layer of the caller's home (layered.HomeRoots, as RootsFor resolves it). The board reads the mode through it; the shell guard reads ReadFetchedFacilitator. A repository with no default branch to read is an error (ErrNoDefaultBranch): a caller that cannot read the mode takes it as human.

func ReadFetchedFacilitator added in v0.16.0

func ReadFetchedFacilitator(cwd string) (Facilitator, error)

ReadFetchedFacilitator is ReadDefaultFacilitator for a caller that judges an act by the mode and so must not take it from refs an agent can move (`git remote set-head`, `git update-ref` on a remote-tracking ref): the shell guard, deciding a merge command. It asks Remote which branch is its default and at which commit (git ls-remote --symref), fetches that branch, and reads the mode at the commit Remote named, from the local object store, all within FetchedReadTimeout. A remote that cannot be asked, a fetch that fails or runs out of time, and a tip the fetch did not bring are errors, which the caller counts as human: it never falls back to the checkout's last fetch. So is a checkout where the forge client would act on another remote than Remote (one named upstream or github, which gh prefers, or one gh repo set-default chose), whose mode this read would not be. The fetch writes what any fetch of the branch writes (its remote-tracking ref), never origin/HEAD and never FETCH_HEAD, and starts no maintenance. The network calls run as Net's do, with the person's own git configuration and credentials and never a prompt, so a private repository reads as it fetches.

It trusts Remote's URL as the checkout's configuration names it: an agent that rewrites the URL is out of its reach, as the guard's limit says.

type FetchError

type FetchError struct {
	Def string
	Err error
}

FetchError is a fetch of the default branch git refused.

func (*FetchError) Error

func (e *FetchError) Error() string

func (*FetchError) Unwrap

func (e *FetchError) Unwrap() error

type ForgeCall added in v0.16.0

type ForgeCall func(args ...string) (string, error)

ForgeCall runs the forge client with args and returns its stdout, or an error carrying its stderr (so a 404 can be told from any other failure).

type GitFunc

type GitFunc func(dir string, args ...string) (string, error)

GitFunc runs one networked git command (a fetch or a push) from dir: gitutil.Net, or a test's seam.

type ListError

type ListError struct{ Err error }

ListError is a ruleset mirror whose listing git refused.

func (*ListError) Error

func (e *ListError) Error() string

func (*ListError) Unwrap

func (e *ListError) Unwrap() error

type MergeDecision added in v0.16.0

type MergeDecision struct {
	Arm    bool
	Method string
	Why    string
	// Unread marks a decision not to arm that rests on an answer the gate could
	// not read: a forge read that failed, or receipts it could not judge. It is
	// no refusal of the head, so nothing is withdrawn on it.
	Unread bool
	// Mode is the facilitator mode the gate ran in (ModeAuto or ModeHuman),
	// as it read it.
	Mode string
	// AuthorCanWrite says the forge named the pull request's author as one
	// who can write to the repository (RoleMaintainer); false for a
	// contributor and for an author whose role is unverified.
	AuthorCanWrite bool
	// ApprovalCounted says a person's approval of the head counted in the
	// answer: a forge review or a recorded approval the gate found standing.
	ApprovalCounted bool
}

MergeDecision is the merge gate's answer to a MergeQuery: whether to arm, with which forge flag, and why.

func DecideMerge added in v0.16.0

func DecideMerge(q MergeQuery) (MergeDecision, error)

DecideMerge gathers the merge gate's inputs for q and decides. Its error is only a facilitator.mode that cannot be read (wrapping ErrModeUnreadable, sanitised); a forge answer that cannot be read is a reason in the decision, never an arming.

type MergeQuery added in v0.16.0

type MergeQuery struct {
	// RepoRoot is a checkout of the repository: its object store holds the
	// default branch's tip, and its worktrees the receipts and approvals.
	RepoRoot string
	// From is the checkout the landing was asked from, when it is not
	// RepoRoot's (abcd land run in one checkout for a branch checked out in
	// another); "" is RepoRoot itself. When From, or else RepoRoot, is a drive
	// lane's worktree or lies inside one, no review receipt or recorded
	// approval is read (fromDriveLane).
	From string
	// Roots supplies the machine layer (Home, HomeRefused); its Repo is not
	// read.
	Roots layered.Roots
	// Tip is the default branch's tip as just fetched, and TipName how it is
	// named ("origin/main"); Default is the branch's name.
	Tip, TipName, Default string
	// Rule is the ruleset mirror's merge rule at Tip.
	Rule MergeRule
	// Repo is the repository as the forge names it ("owner/name"), or gh's
	// "{owner}/{repo}" for the checkout's own.
	Repo string
	// PR is the pull request's number and Head its head commit, the one the
	// landing gated.
	PR, Head string
	// Forge runs the forge client, its error carrying stderr.
	Forge ForgeCall
}

MergeQuery is what the merge gate is asked about one pull request.

type MergeRule

type MergeRule struct {
	Method string
}

MergeRule is the ruleset mirror read at a commit: the merge queue's method ("" when no merge queue gates the default branch). A pull-request rule's approval requirement is not read: ruling AM1, which armed only where one required a person's approval, is retired, and the merge gate (facilitator.go) reads approvals from the forge itself.

func ReadMergeRule

func ReadMergeRule(repoRoot, base, def, at string) (MergeRule, error)

ReadMergeRule reads the ruleset mirror at the commit base in the repository at repoRoot, for the default branch def. A missing mirror requires nothing. The base is a commit of the default branch (a lane's base, or the merge base of a branch with the default branch), so the branch's own commits cannot change the rule it lands by. at names base in a refusal ("the lane's base"). A mirror that cannot be read is a *MirrorError, a listing git refused a *ListError.

type MergedListingFullError

type MergedListingFullError struct {
	Branch string
	Listed int
}

MergedListingFullError is a listing of a branch's merged pull requests that the bound filled with none at the head: the proof may lie past the bound, so the listing cannot say the head has not merged.

func (*MergedListingFullError) Error

func (e *MergedListingFullError) Error() string

type MirrorError

type MirrorError struct {
	Reason string
	Fix    string
}

MirrorError is a ruleset mirror that cannot be read into a merge rule: Reason says what is wrong and Fix what settles it. A caller adds what to run once it is settled.

func (*MirrorError) Error

func (e *MirrorError) Error() string

type Options

type Options struct {
	// Branch is the branch to land; "" is the checkout's current branch.
	Branch string
	// NoPush and NoEnqueue are --no-push and --no-enqueue.
	NoPush    bool
	NoEnqueue bool
	// Roots are where land.push and land.enqueue are read: the working
	// directory's repository layer and the machine layer. The landed branch's
	// own checkout is read as a repository layer beside them.
	Roots layered.Roots
	// Forge runs the forge client with args from dir.
	Forge func(dir string, args ...string) (string, error)
	// Git runs one networked git command (a push, a fetch, or the ls-remote
	// that asks origin for its default branch) from dir.
	Git GitFunc
	// Gate runs the preflight in the branch's checkout at dir.
	Gate func(dir string) error
	// GateOutput receives the preflight's output; nil discards it.
	GateOutput io.Writer
	// Sleep pauses between the forge readings that wait for land's own push
	// to show; nil is time.Sleep.
	Sleep func(time.Duration)
	// Now is the clock the enqueue step judges a pull request's dependencies
	// by (depends.go); nil is time.Now.
	Now func() time.Time
	// StopRead reads a person's stop; nil is the read every other verb makes.
	StopRead func() runstop.Reading
	// Announce is the options the announcements before the push are made
	// with (announce.go): its Home "" is Roots.Home, its Embargo nil the
	// check `abcd announce` uses, its ForgeUser nil the forge's user
	// endpoint, asked only when git's identity does not name the sender.
	Announce claim.Options
	// contains filtered or unexported fields
}

Options are one landing's inputs and its seams. A nil seam takes the real one: Forge is GH, Git is gitutil.Net (the networked git runner, hooks running), Gate runs `make preflight`.

type Refusal

type Refusal struct {
	Reason string
	Fix    string
	Held   bool
}

Refusal is a landing refused: Reason says why, Fix what settles it. Held marks a landing a release being cut holds (releaseHold) or a person's stop holds (stopHold): contention, which the surface exits 3 on, as every verb that backs off does.

func (*Refusal) Error

func (r *Refusal) Error() string

type Result

type Result struct {
	Branch   string `json:"branch"`
	Head     string `json:"head"`
	Checkout string `json:"checkout"`
	Default  string `json:"default_branch"`
	Push     Switch `json:"push"`
	Enqueue  Switch `json:"enqueue"`
	PR       int    `json:"pull_request,omitempty"`
	PRURL    string `json:"pull_request_url,omitempty"`
	// Pushed is the commit the push step sent, the head the gate checked.
	Pushed string `json:"pushed,omitempty"`
	// Landed is set when the head was already on the default branch, or the
	// forge lists PR as merged at it.
	Landed bool   `json:"landed,omitempty"`
	Steps  []Step `json:"steps"`
	// Notices are lines the landing shows beside its steps, whatever its
	// outcome: each release dated ahead that the release hold did not count.
	Notices []string `json:"notices,omitempty"`
}

Result is the landing's report, filled as far as it got: a refused landing returns the steps it completed beside the refusal.

func Land

func Land(cwd string, o Options) (Result, error)

Land lands the branch from the checkout at cwd.

type Review added in v0.17.0

type Review struct {
	Login, State, Commit string
	Index                int
}

Review is one review as a page of a pull request's reviews lists it, oldest first: its reviewer's login ("" for none the forge names), its state, and the commit it reviewed. Index is its place on the page, which LatestReviews sets so a caller can go back to the rest of what it read.

func LatestReviews added in v0.17.0

func LatestReviews(page []Review) []Review

LatestReviews is the merge gate's reading of a page of reviews: the latest submitted review of each reviewer, in the order they first reviewed. A pending review is the reviewer's own draft, not a review, and a review that names no reviewer is no one's; every other state, a dismissed one included, is the reviewer's latest word, so it supersedes an earlier approval. Reviewers are told apart without regard to case, as the forge's logins are.

func (Review) Approves added in v0.17.0

func (r Review) Approves(head, author string) (note string, ok bool)

Approves says whether r, a reviewer's latest review, approves head on a pull request author opened, before anything is asked of the reviewer's access: it is APPROVED, of head, by someone other than author. note says why one that approved something does not count, "" for a review that approves nothing; with no author known, no review can be told from the author's own, so none counts.

type ReviewReturn added in v0.16.0

type ReviewReturn struct {
	Name string
	Text string
}

ReviewReturn is one reviewer's return: the name it is recorded under and its text, which states what it read and states its verdict under one `### Verdict` heading, naming the head it judges.

type Step

type Step struct {
	Name    string `json:"name"`
	Status  string `json:"status"`
	Note    string `json:"note"`
	Command string `json:"command,omitempty"`
}

Step is what one step of the landing did.

type Switch

type Switch struct {
	Key    string `json:"key"`
	On     bool   `json:"on"`
	Layer  string `json:"layer"`
	Origin string `json:"origin"`
}

Switch is one of the landing's two outward acts as configured: whether it is on, and the layer and origin that decided it — the bundled default when no layer turned it off, else the highest layer that did.

Jump to

Keyboard shortcuts

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