Documentation
¶
Overview ¶
Package landings reads how each change reached the default branch (itd-2610301850454860, spc-2610301950480609).
This file is the grammar of the one fact the implement loop writes before a change merges: the rule a lane was admitted under, carried as an `Admitted-by:` trailer on the landing's records commit, which the merge brings into the default branch's history. It is the one spelling: the loop composes the trailer through Admitted.Trailer, and the reader and the tests read it back through ParseAdmitted.
Index ¶
Constants ¶
const ( // KindDrain is a lane the drain opened on an issue its rule record lets it // take alone; the record is that rule's ADR id. KindDrain = "drain" // KindBuild is a lane `abcd build` opened: the record is the spec the run // builds against, or the issue a person's `abcd build <iss-N>` fixes. KindBuild = "build" )
The lane kinds a trailer names.
const ( // ClassPersonPush is a first-parent commit whose subject names no pull // request, or names one the forge answered for and says did not merge as // that commit: the shape of a commit pushed to the default branch, which a // rebase merge's commits share. The class confirms no person, in either // mode: the row is unattended unless a recorded approval of the commit // itself is found. ClassPersonPush = "person-push" // ClassPersonApproved is a merge a person approved: a recorded approval of // its merged head, a forge review approving that head by someone other // than the pull request's author, or the human mode its first parent // committed, each for a merge the forge's answer was read for and says // merged as that commit. ClassPersonApproved = "person-approved" // ClassDrain is a merge under auto with no approval seen whose branch // carries the drain's admission, or such a merge in either mode whose // forge answer was not read. ClassDrain = "drain" // ClassAutomatic is every other merge under auto with no approval seen, // and every other merge in either mode with no approval seen whose forge // answer was not read. ClassAutomatic = "automatic" )
The four classes, decided in this order.
const ( SourceForge = "forge" SourceLocalTier = "local tier" SourceNoneSeen = "none seen" SourceForgeUnread = "forge unread" )
Where a row's approval was read.
const ( // ModeModeless is a first parent that holds no .abcd/config.json, or a // row with no first parent; it reads as human, the bundled default. ModeModeless = "modeless" // ModeUnreadable is a first parent whose .abcd/config.json cannot be read // or judged; it never reads as human, so no row is a person's by it. ModeUnreadable = "unreadable" )
The modes a row records beside landing.ModeHuman and landing.ModeAuto.
const ( // RevertGit is git revert's own line, "This reverts commit <sha>". RevertGit = "revert" // RevertForge is the forge's own line in a squashed revert's pull request // body, "Reverts #N" or "Reverts <owner>/<repo>#N". RevertForge = "forge" // RevertUntraceable is a commit whose subject is git revert's, `Revert // "<subject>"`, with neither line: it marks nothing. RevertUntraceable = "untraceable" )
The kinds of a revert line, and of a mark.
const CacheRelDir = landing.TierRelDir + "/landings"
CacheRelDir is the forge cache, in the listing checkout's local tier: one file per pull request, pr-<N>.json. It holds the forge logins a row prints, so it lives in the gitignored tier and never in a committed file.
const GroupUntraceable = "untraceable"
GroupUntraceable is the group the reverted groups hold untraceable reverts in, apart from the groups by rule.
const LaneUnknown = "unknown"
LaneUnknown is the lane kind of a row whose branch carries no admission, or two that differ, or whose commits the forge could not give.
const MaxBatch = 20
MaxBatch is the most pull requests one forge document asks about.
const ReleaseTagPattern = "v*"
ReleaseTagPattern is the tags `git describe` takes the default range from.
const RuleForgeUnread = "forge unread"
RuleForgeUnread is the kind, and the whole name, of the Rule of a merge under the human mode whose forge answer was not read: no rule read admits it, and the human mode attends only a merge the forge's answer confirms.
const RuleMode = landing.KeyFacilitatorMode
RuleMode is the kind of a Rule that names facilitator.mode.
const SaysNotOnDefault = "not on the default branch"
SaysNotOnDefault is what the positional trace says of a commit no first-parent commit of the default branch brought.
const TrailerKey = "Admitted-by"
TrailerKey is the trailer's key.
Variables ¶
var ErrBadSince = errors.New("the range's start names neither a tag nor a date")
ErrBadSince is what every since that names neither a tag the repository holds nor a date is (errors.Is), and one naming a tag git says points at no commit, so the verb refuses it as a range it was not given. A since whose tag could not be read is a failed read, never this.
var ErrNoDefaultBranch = errors.New("the repository has no default branch to list the landings of")
ErrNoDefaultBranch is resolve's answer for a repository with no default branch to list.
var ErrNoReleaseTag = errors.New("no release tag (v*) is reachable from the default branch, so there is no range to list by default; name where to start with --since <tag|YYYY-MM-DD>")
ErrNoReleaseTag is resolve's answer when no since is named and no release tag is reachable from the default branch: there is no default range.
var ErrReleaseTagUnnamed = errors.New("the last release tag git describes names no tag this repository holds")
ErrReleaseTagUnnamed is what resolve's refusal is (errors.Is) when the last release tag git describes names no tag the repository holds: git describes an annotated tag by the name stored inside it, which a ref renamed since no longer carries. As with no release tag, there is no range to list by default, and the person names one.
Functions ¶
This section is empty.
Types ¶
type Admitted ¶
type Admitted struct {
// Kind is KindDrain or KindBuild.
Kind string `json:"kind"`
// Record is the drain rule's ADR id (adr-N), the spec id (spc-N), or the
// issue id (iss-N).
Record string `json:"record"`
// Path is the drain rule record's repo-relative, slash-separated path, for
// a drain's admission only. The trailer does not carry it: a reader finds
// the record by its id.
Path string `json:"path,omitempty"`
}
Admitted is the rule a lane was admitted under.
func ParseAdmitted ¶
ParseAdmitted reads the admission a commit message's trailer block (its last paragraph, as git reads trailers) carries. It reports false when the block carries none, carries two that differ, or carries one the loop never writes; the path is never in a trailer, so the one returned has none.
func (Admitted) Check ¶
Check says why a is not an admission the loop writes, or "" when it is: a drain's names an ADR id in its canonical spelling and that record's path in the decision store, and a build's names a spec or an issue id and no path. The trailer is written from it into a commit message, so nothing else, a line break above all, ever reaches one.
type Approval ¶
type Approval struct {
Seen bool `json:"seen"`
By string `json:"by,omitempty"`
At time.Time `json:"at,omitzero"`
Source string `json:"source,omitempty"`
}
Approval is the approval a row's class rests on, and where it was looked for. Seen is true for a recorded approval or a counted forge review; By and At are the forge reviewer's login and the review's time.
type Listing ¶
type Listing struct {
Tip string `json:"tip"`
From string `json:"from"`
To string `json:"to"`
Since string `json:"since"`
// SinceNote says what a reader of the range should know of how From was
// found (Range.Note), "" for nothing.
SinceNote string `json:"since_note,omitempty"`
Rows []Row `json:"rows"`
// ForgeUnread says why the forge did not answer for some row, "" when it
// answered for every row that names a pull request; it opens with the
// count of rows whose answer was not read (unreadNote).
ForgeUnread string `json:"forge_unread,omitempty"`
// CacheUnwritten says why an answer could not be kept in the forge cache.
CacheUnwritten string `json:"cache_unwritten,omitempty"`
// ModeUnread says why the facilitator mode some first parent committed
// could not be read, "" when every one read; such a row's mode is
// ModeUnreadable.
ModeUnread string `json:"mode_unread,omitempty"`
}
Listing is list's answer.
func List ¶
List is the reader's entry, which abcd landings and the spot-check call.
List reads every first-parent commit of r on the repository at repoRoot, newest first, and classes each. It fetches nothing; it writes only its forge cache in repoRoot's local tier. Every git call and every forge call is bound to ctx, or to listBound when ctx sets no deadline, and each forge batch also to landing.ForgeTimeout. A ctx that ends before the listing is done is the error, whatever the read it ended was.
type Options ¶
type Options struct {
// Forge runs the forge client; nil is landing.GHAnswerContext bound to
// list's ctx, run in repoRoot.
Forge landing.ForgeCall
// Worktrees are where recorded approvals are looked for; nil lists the
// worktrees git knows for repoRoot, once.
Worktrees []gitutil.Worktree
}
Options are list's seams.
type Range ¶
Range is the stretch of the default branch a listing reads: From exclusive ("" for the whole history up to To) and To inclusive, full object names. Tip and Since are how the caller named them (the remote-tracking ref To was read from, and the tag or date From was taken from), and Note what resolve has to say of how it found From; list copies the three into the listing, masked, and reads none of them.
func Resolve ¶
Resolve is the Range from since to the default branch's tip as the repository at repoRoot last fetched it, as abcd landings names it.
since is a tag, a date YYYY-MM-DD (taken in UTC as the start of that day: the range opens at the first commit on the tip's first-parent line, oldest first, committed at or after it, so From is the commit before that one), or "" for the last release tag reachable from the tip (git describe --tags --match 'v*' --abbrev=0). A committer date is whatever the commit's maker set, so where a commit inside a date's range is dated before the day, the range's Note says so; where a tag is not on the tip's first-parent line, the Note says what that range then holds. Every git question is bound to ctx, or to listBound when ctx sets no deadline, and a ctx that ends first is the error, whatever the question it ended was.
type Revert ¶
type Revert struct {
By string `json:"by"`
ByRow string `json:"by_row"`
Kind string `json:"kind"`
WithdrawnBy string `json:"withdrawn_by,omitempty"`
}
Revert is the mark on a row a later commit reverts: the reverting commit, the row that brought it, the line's kind, and, where that revert is itself reverted by a revert that stands, the commit that withdrew it (the row's change is then reinstated, as RS001's withdrawn_by reads it).
type RevertGroup ¶
type RevertGroup struct {
Rule string `json:"rule"`
Count int `json:"count"`
Rows []Row `json:"rows"`
}
RevertGroup is one group of reverted rows: the rule that admitted them (as Rule.String names it, "person-push" for a person's push), or GroupUntraceable for the rows carrying an untraceable revert; how many; and the rows, newest first.
func RevertedGroups ¶
func RevertedGroups(l Listing) []RevertGroup
RevertedGroups is l's reverted rows grouped by rule, each group where its newest row falls, and the untraceable reverts in a group of their own, last. A row whose revert was withdrawn is grouped with the rest: its change was reverted, and its mark says it was reinstated. A group is the rule's, not the class's, so one may hold attended and unattended rows (a row a person approved under auto shares the auto group with the automatic rows); each row carries its own Unattended, which a reader splits the group by.
type RevertLine ¶
type RevertLine struct {
Commit string `json:"commit"`
Kind string `json:"kind"`
Names string `json:"names,omitempty"`
Target string `json:"target,omitempty"`
Row string `json:"row,omitempty"`
Unmarked string `json:"unmarked,omitempty"`
}
RevertLine is one revert line a row's commits carry, or one untraceable revert: the commit carrying it (the row's own commit for the forge's line), its kind, the name as written (a hex name, or "#N" or "<owner>/<repo>#N"), the full name it resolved to, and the row it marks, or why it marks none.
type Row ¶
type Row struct {
Commit string `json:"commit"`
When time.Time `json:"when"`
// PR is the pull request the subject names, 0 for none. On a person-push
// row the forge contradicted (ForgeSays set), it is the number the subject
// named, not a merged pull request.
PR int `json:"pr,omitempty"`
// MergedHead is the head the merge brought: the second parent, or the
// forge's head for a one-parent row that names a pull request; "" on a row
// the forge contradicted.
MergedHead string `json:"merged_head,omitempty"`
// Committer is git's committer name, for a person's push.
Committer string `json:"committer,omitempty"`
Class string `json:"class"`
Rule Rule `json:"rule"`
Lane string `json:"lane,omitempty"`
Approval Approval `json:"approval"`
Mode string `json:"mode"`
// Resolves, Delivers and AssistedBy are the trailers of the commits the
// row brought, once each.
Resolves []string `json:"resolves,omitempty"`
Delivers []string `json:"delivers,omitempty"`
AssistedBy []string `json:"assisted_by,omitempty"`
// ForgeSays is what the forge answered against the pull request the
// subject names, for a person-push row whose subject names one: "" for
// every other row.
ForgeSays string `json:"forge_says,omitempty"`
// ForgeUnreadable says why the forge's answer for the pull request the
// subject names was not read, whatever the cause (an answer too large to
// read even asked alone among them): no mode attends such a row. "" for
// every other row.
ForgeUnreadable string `json:"forge_unreadable,omitempty"`
// Unattended marks a row no evidence places with a person.
Unattended bool `json:"unattended"`
// Reverted marks a row a later commit on the default branch reverts
// (revert.go), nil for none; it changes nothing else on the row.
Reverted *Revert `json:"reverted,omitempty"`
// Reverts are the revert lines the row's commits carry, and its
// untraceable reverts, each with the row it marks or why it marks none.
Reverts []RevertLine `json:"reverts,omitempty"`
}
Row is one first-parent commit and how it landed.
type Rule ¶
type Rule struct {
Kind string `json:"kind,omitempty"`
ID string `json:"id,omitempty"`
Path string `json:"path,omitempty"`
At string `json:"at,omitempty"`
}
Rule is what admitted a row: a drain rule record by its id and path, or facilitator.mode by its value as .abcd/config.json held it at At (the first parent). A person's push names none, and a merge under the human mode whose forge answer was not read names RuleForgeUnread alone.
type Trace ¶
type Trace struct {
Commit string `json:"commit,omitempty"`
Says string `json:"says,omitempty"`
Row *Row `json:"row,omitempty"`
Reverts []Row `json:"reverts,omitempty"`
Tip string `json:"tip"`
To string `json:"to"`
From string `json:"from,omitempty"`
RangeNote string `json:"range_note,omitempty"`
ForgeUnread string `json:"forge_unread,omitempty"`
CacheUnwritten string `json:"cache_unwritten,omitempty"`
ModeUnread string `json:"mode_unread,omitempty"`
}
Trace is what the positional trace says of one commit: its full name; what stops it having a row (SaysNotOnDefault, or why the name names no commit); the row that brought it onto the default branch, as a listing over the range From says classes and marks it; and the rows that row's revert lines mark in that listing, each classed and marked as the listing has it. RangeNote says why the range may not hold a row one of its lines names, "" when it holds every one. Tip and To are the tip read, and the notes are the listing's.
A traced row reads as a listing over a longer range reads it but in these ways. The reverted rows' own revert lines are read over the trace's range, which may start at them, so their lines can say "outside the listed range". A line past the maxTraceTargets the trace looks for keeps its reason, which then says the bound was reached. And every bound a listing holds is the listing's own and spent oldest row first: the maxRevertLines git lines it follows, and the maxHalvingCalls of asking again that its pull request batches and then its bodies share. So a listing from an older start can leave unfollowed or unread a line or a body that the trace's shorter range follows or reads, and the widened listing can do the same to the traced row's own lines.
func TraceCommit ¶
TraceCommit is the positional trace (the spec's Trace): name, a full or abbreviated hex name, resolved by git from stored objects alone, followed to the first-parent commit of the default branch's tip, as last fetched, that brought it, however far back. Its row is read from a listing, so it is classed and marked as the listing classes and marks it, the forge asked as the listing asks it, and its reverts are the rows that listing's lines of that row mark, by the listing's own rules. The listing runs from the traced row to the tip; where the row's lines name a commit before it, or a pull request no row of it merged, the range is widened once to the oldest row they name (at most maxTraceTargets looked for), and RangeNote says what it could not place. So a trace reads at most two listings, and beside them asks git, before the first: the default branch's ref questions (gitutil.DefaultRefContext), the tip's commit (commitOf), the name's objects and their types (resolveNames, at most two calls), the first-parent line (firstParentLine) and the traced commit's ancestry path (rowOn); and between the two: one ancestry path for each commit looked for (at most maxTraceTargets) and one log of the older commits' messages. Every one of them but the ref questions, as every call of the listings', reads objects as stored. The ref questions read refs, the type of the object each names and, for a tag, of the object it points at, and peel a ref to its commit as git resolves it, only to choose the default branch's ref, whose tip commitOf then reads as stored. It fetches nothing, writes only the listing's forge cache, and binds every call to ctx as List does.