Documentation
¶
Overview ¶
Package finish closes a task: it decides what landing means, lands the request, archives what the task leaves and cleans up its checkout, workspace and branch.
Index ¶
- Constants
- Variables
- func CloseChoice(task ref.Ref, value string, resolve func(string) (ref.Ref, error)) ([]string, error)
- func CloseSeries(dir string, end archive.SeriesEnd) (string, error)
- func ClosedChange(dir string, end archive.SeriesEnd) (string, bool)
- func Finish(ctx context.Context, w io.Writer, in FinishInput) error
- func FinishedEvent(id, by string, at time.Time) ledger.Event
- func Janitor(ctx context.Context, in JanitorInput) ([]string, error)
- func JanitorDefault(ctx context.Context, main string) (string, error)
- func KeepOpen(body, number string) string
- func LandingBase(ctx context.Context, dir, def string) (string, error)
- func Lease(root, id string) (*drivestore.Lease, error)
- func ProcessPlace() (string, string, error)
- func ReadPendingPull(root string) (string, string)
- func Ref(ctx context.Context, t *target.Target, token string) (ref.Ref, string, string, error)
- func RetryPendingPull(ctx context.Context, root, main string) (string, bool)
- func SweepIfDue(ctx context.Context, w io.Writer, stamp string, now time.Time, ...)
- func TaskBranches(ctx context.Context, in JanitorInput, def string) ([]staleBranch, map[string]bool, error)
- func TaskSpike(checkout string, root storage.Root, id string) string
- func TouchStamp(stamp string, now time.Time) error
- type ChecksError
- type FinishInput
- type Flags
- type ForeignPullError
- type JanitorInput
- type RidersError
- type Sweeper
Constants ¶
const ChecksBudget = 20 * time.Minute
ChecksBudget is how long a pending head may hold a finish, interactive or driven, before it is refused as if red.
const JanitorStamp = "janitor.stamp"
JanitorStamp's mtime is the last run.
const PendingPullFile = "pending-pull"
PendingPullFile, in the storage root every checkout shares, records a deferred pull as "<default branch> <merge sha>". Only the newest sha matters, since origin's branch holds every earlier merge too.
Variables ¶
var ChecksPoll = 15 * time.Second
ChecksPoll is how often a waiting finish reads the checks again.
var ClosingRE = regexp.MustCompile(fmt.Sprintf(closingKeyword, `\d+`))
ClosingRE reads any closing keyword before any issue number.
Functions ¶
func CloseChoice ¶
func CloseChoice(task ref.Ref, value string, resolve func(string) (ref.Ref, error)) ([]string, error)
CloseChoice reads --close; a token outside the bundle is a typo, refused.
func CloseSeries ¶
CloseSeries ends the task's series even when it had no review rounds, since the archive is what counts a task's PRs for its lore change; a series already closed with the same PR or head (finish run again) adds none.
func ClosedChange ¶
ClosedChange is the change of the PR end closed, when the newest archived PR is that one: a finish run again after its merge reports on it, not on the next series.
func Finish ¶
Finish runs in the order the refusals need: every refusal before anything changes, the report before anything local goes, and the workspace close last, since on the self-close path the close ends this process.
func FinishedEvent ¶
FinishedEvent records a finish that ran in this process, where no hook sees it; by names who ran it, "" for the drive.
func Janitor ¶
func Janitor(ctx context.Context, in JanitorInput) ([]string, error)
Janitor reports a line per removal, and per branch kept for a reason worth knowing.
func JanitorDefault ¶
JanitorDefault falls back to the main checkout's branch only with no origin.
func LandingBase ¶
LandingBase is the local default branch, or origin's copy when the local one is only behind it, so origin's commits are never folded into the merge.
func ProcessPlace ¶
ProcessPlace is this process's directory and workspace, for finish's self-close check.
func ReadPendingPull ¶
func Ref ¶
Ref is the task a token names, its suffix, and for a bare call the branch checked out here, which picks it among suffixed siblings. The session's task is refused: nothing else would stand between it and a merge.
func RetryPendingPull ¶
RetryPendingPull retries a pull a finish deferred. It reports "" with no pull pending, else what happened, and whether the pull is still pending.
func SweepIfDue ¶
func SweepIfDue(ctx context.Context, w io.Writer, stamp string, now time.Time, run func(context.Context) ([]string, error), )
SweepIfDue never fails the command that ran it: an error is one warning. The stamp moves first, so commands in quick succession run it once.
func TaskBranches ¶
func TaskBranches(ctx context.Context, in JanitorInput, def string) ([]staleBranch, map[string]bool, error)
TaskBranches reads a branch as finish does: its link or recorded bundle, else its name. On origin a bare id counts only in the shapes start creates, so a name merely mentioning one is someone else's. held is every branch a checkout has, main's included.
Types ¶
type ChecksError ¶ added in v0.60.0
type ChecksError struct {
URL string
Checks forge.HeadChecks
Waited time.Duration
}
A ChecksError refuses a merge on the head's checks, with nothing changed; Waited is how long this finish waited on them.
func (ChecksError) Error ¶ added in v0.60.0
func (e ChecksError) Error() string
func (ChecksError) Pending ¶ added in v0.60.0
func (e ChecksError) Pending() bool
Pending reports a head whose checks were still running when refused.
type FinishInput ¶
type FinishInput struct {
Main string // the main checkout: host and git commands run here
Root string // the shared storage root, for the pull's lease; "" takes none
Driver *trackerdriver.Driver // nil without one
Task ref.Ref
Change string // the lore change this merge closes; finish fills it from the task's series
Suffix string
Branch string // a bare call's own branch, "" to look it up by task and suffix
Host hostops.Host
Method string // the merge method project.md declares, "" for none
Traces bool // traces: on; the squash or merge commit's body ends in the task's trailers
// HostCloses: a merge's closing keyword closes the task (target.HostCloses)
HostCloses bool
// LoreStore feeds the report's lore line and the pre-merge check (nil reads
// nothing); gate is lore_gate: warn notes a failing check, block refuses
LoreStore *lore.Store
Gate string
Cwd string // where the command runs: inside the worktree is the self-close case
Workspace string // HERDR_WORKSPACE_ID: the workspace this process runs in, or ""
Flags Flags
Storage storage.Root // the same root as root, for task files: plans, findings, handoffs
// Title reads the task's title for a squash merged here, nil for none
Title func(context.Context) (string, error)
// Close is the riders the PR delivers, closed with the lead; nil, no
// --close answer yet, refuses a bundle's merge unless FollowBody
Close []string
// FollowBody takes a nil Close from the PR body's closing keywords, for
// the drive and the watcher, which have no one to ask
FollowBody bool
// Sweep runs the janitor before the workspace closes, since a self-close
// ends the process; nil for none
Sweep func(context.Context)
// Progress names each action as it starts, for drive's record; nil for none
Progress func(string)
// Handoff takes the lines a merge prints under its report, for drive's report; nil for none
Handoff func([]string)
// Deferred takes a deferred pull's note, for drive's report; nil for none
Deferred func(string)
// Subtasks is every subtask, closed ones kept, for a parent with no branch;
// nil, like ErrNoParentLink, is a tracker with no parent link
Subtasks func(context.Context, ref.Ref) ([]stack.ChildRow, error)
// CloseTask closes a parent its subtasks delivered; nil where the tracker is
// not the host, which f10 has no "done" word for
CloseTask func(context.Context, ref.Ref) error
// ChecksWait is how long a pending head may hold the merge; zero refuses it
// at once, for the drive, which holds the task itself
ChecksWait time.Duration
}
FinishInput is everything finish needs once the target is settled, so the flow can be tested without a checkout.
type Flags ¶
type Flags struct {
Yes bool // close the workspace finish runs in, after the report
Merge bool // merge the PR even when someone else opened it
LeaveOpen bool // --local: leave the PR open and clean up only what is here
Keep bool // a spike's experiment is committed onto a kept/ branch, not discarded
// MergedOnly refuses all but an already merged request: the watcher never merges
MergedOnly bool
// IgnoreChecks merges past red or pending checks; --yes never implies it,
// since automated finishes pass --yes
IgnoreChecks bool
}
Flags are the caller's choices; everything else finish derives.
type ForeignPullError ¶
A ForeignPullError is a refusal: nothing changed, the choice is the user's.
func (ForeignPullError) Error ¶
func (e ForeignPullError) Error() string
type JanitorInput ¶
type JanitorInput struct {
Main string
Host *hostops.Host // nil without a host CLI: only branches never pushed qualify
Prefix string
Storage storage.Root
Dry bool
// LocalOnly: the watcher asks the network nothing before the host
LocalOnly bool
}
JanitorInput is everything the janitor needs, so it runs in a test without a checkout.
func JanitorFor ¶
func JanitorFor(t *target.Target) JanitorInput
type RidersError ¶
type RidersError struct {
// contains filtered or unexported fields
}
A RidersError is a bundle finished without --close: nothing changed.
func (RidersError) Error ¶
func (e RidersError) Error() string
type Sweeper ¶
type Sweeper struct {
In JanitorInput
Def string
Lines []string
// contains filtered or unexported fields
}
A Sweeper is one janitor run: its lines, and the host login read once.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package finishtest holds the janitor fixture, which both finish's janitor tests and the drive's watch tests start from.
|
Package finishtest holds the janitor fixture, which both finish's janitor tests and the drive's watch tests start from. |