Documentation
¶
Overview ¶
Package plan is the GitHub plugin's round planner: over the plugin's pull requests and the host's round state, books, events and workspaces, it decides which automatic rounds are due, why, and what each covers.
Index ¶
- Constants
- func ActiveBlock(evs []pr.Event, viewer string) (pr.Event, bool)
- func LastPublished(b src.Book, role string) (head string, at time.Time, ok bool)
- func NewestReview(b src.Book) (time.Time, bool)
- func StartBlock(ev pr.Event) bool
- type Board
- type Checkout
- type Config
- type Git
- type Inputs
- type Planner
- func (p *Planner) BoardOf(ref pr.Ref, r Result) Board
- func (p *Planner) Derive(ref pr.Ref) (Result, error)
- func (p *Planner) Facts(ref pr.Ref, r Result) []src.Fact
- func (p *Planner) Plan(ref pr.Ref, r Result) src.Plan
- func (p *Planner) RankOf(ref pr.Ref, r Result) Rank
- func (p *Planner) Requested(ref pr.Ref) bool
- func (p *Planner) Settle(ref pr.Ref, r Result) Settlement
- type Project
- type Rank
- type Result
- type Settlement
Constants ¶
const ( // MarkReviewed is my last review and the head on a pull request I review. MarkReviewed = "reviewed" // MarkAddressedReviews is the newest review an address round triaged on // a pull request I develop. MarkAddressedReviews = "addressed.reviews" // MarkAddressedChecks is the head whose failing checks an address round // covered. MarkAddressedChecks = "addressed.checks" // MarkAddressedConflict is the head whose conflict with the base an // address round covered. MarkAddressedConflict = "addressed.conflict" // MarkFirstSkipped is set when the user skipped the automatic first // round; the planner plans no other one. MarkFirstSkipped = "first.skipped" )
The marks the rounds of a pull request write, by what they covered; the host keeps them and hands them back in the round state.
const ( RoundFollowup = "follow-up" RoundFirst = "first" RoundAddress = "address" )
The rounds a plan names.
const ( // WhyPartial is why no round is due while the workspace listing may // miss a workspace. WhyPartial = "the workspace listing is incomplete, no rounds this sweep" )
Variables ¶
This section is empty.
Functions ¶
func ActiveBlock ¶
ActiveBlock is the round_blocked event that still holds among evs, in time order: none has cleared it since, by an unblock, a sent or held round, or a review of mine after it.
func LastPublished ¶
LastPublished is the head and time of the newest verdict a turn of role published in b: the head its last record covered, else the turn's.
func NewestReview ¶
NewestReview is when b's newest review turn was sent.
func StartBlock ¶
StartBlock says ev is the host's start block of a round, which names the agent's question or an untrusted folder in its key; any other block is the planner's.
Types ¶
type Board ¶
type Board struct {
// Carded says a workspace targets the pull request.
Carded bool `json:"carded,omitempty"`
ReviewWorkspace bool `json:"review_workspace,omitempty"`
// AuthorWorkspace says an author workspace targets it and holds no
// address round, nor one a partial listing hides.
AuthorWorkspace bool `json:"author_workspace,omitempty"`
// Checkout is the author workspace an author card reads; nil for none.
Checkout *Checkout `json:"checkout,omitempty"`
}
Board is what the host's board reads of a pull request's workspaces: the review and author workspaces the planner targets it with, and the one an author card reads its checkout from.
type Config ¶
type Config struct {
ReviewPrefix string
// Owners restricts automated rounds to these owners; empty means the
// owners of every repository the workspace managers know.
Owners []string
TrustedAuthors []string
FollowupsWithoutWorkspace bool
AddressWithoutWorkspace bool
AddressReviews bool
AddressSkipReviewers []string
AddressChecks bool
IgnoreChecks []string
AddressConflicts bool
// Completed are the completed columns of the boards.
Completed []string
Fast, Slow time.Duration
Projects []Project
}
Config is what the planner reads of the configuration: GitHub's settings, the board columns a finished review workspace sits in, the sweeps' intervals and the projects that override some settings.
type Git ¶
type Git interface {
// Upstream is the remote branch the checkout at dir pushes to; "" for
// none.
Upstream(ctx context.Context, dir string) (string, error)
LocalBranchTip(ctx context.Context, dir, branch string) (string, error)
// CheckedOutAt is the worktree that has branch checked out; "" for none.
CheckedOutAt(ctx context.Context, dir, branch string) (string, error)
HasCommit(ctx context.Context, dir, oid string) (bool, error)
IsAncestor(ctx context.Context, dir, ancestor, commit string) (bool, error)
}
Git reads what a round would find of a pull request's branches in a local checkout.
type Inputs ¶
type Inputs struct {
Now time.Time
Viewer string
Rows []pr.PR
// Details are the stored full reads; one of another version is no read.
Details map[pr.Ref]store.Detail
// Adopted are the pull requests taken over into the loop.
Adopted map[pr.Ref]bool
// Wanted is the profile's review_wanted, by pull request; one it does
// not name is wanted when it requests the viewer's review by name.
Wanted map[pr.Ref]bool
Books map[pr.Ref]src.Book
Rounds map[pr.Ref]src.RoundState
Events map[pr.Ref][]pr.Event
Listing src.Listing
// Unlisted says the workspaces could not be read: no round is due.
Unlisted bool
// Git nil reads no checkout.
Git Git
Cfg Config
}
Inputs are everything the planner reads at one instant: the plugin's stored pull requests, and the host's books, round state, events and workspaces.
type Planner ¶
type Planner struct {
// contains filtered or unexported fields
}
Planner derives results over one read of its inputs.
func (*Planner) Plan ¶
Plan is the rounds r plans on ref, each with the marks the host writes when it sends or skips it.
type Project ¶
type Project struct {
Match string
TrustedAuthors []string
FollowupsWithoutWorkspace *bool
AddressWithoutWorkspace *bool
}
Project overrides some settings for the repositories its match names; nil keeps the top-level value.
type Rank ¶
type Rank struct {
Path int `json:"path"`
At time.Time `json:"at,omitzero"`
Idx int `json:"idx,omitempty"`
}
Rank orders units as the rounds are planned: follow-ups by their review's time, first rounds by the pull request's age, address rounds by their workspace's place and then among my pull requests, then the units no round is due on.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result is what the review, first-round and address rules decide on one pull request; the host's turn.start guards filter it further.