Documentation
¶
Overview ¶
Package reviews reads and settles the reviews on a task's request: the host reviewer, the request a branch or task names, and the findings rounds.
Index ¶
- Variables
- func BranchTask(ctx context.Context, t *target.Target, main, branch string) *ref.Ref
- func CapturedHead(ctx context.Context, dir string) (string, error)
- func LastPullOf(ctx context.Context, t *target.Target, branch string) (forge.PR, error)
- func MergedTree(ctx context.Context, dir, head, base string) (string, string, error)
- func OpenPullOf(ctx context.Context, t *target.Target, branch string) (forge.PR, error)
- func OpenReviews(ctx context.Context, t *target.Target, explicit string, warn io.Writer) (string, roundSeries, error)
- func PullNumberOf(token string) int
- func ResolvePRSubject(ctx context.Context, t *target.Target, token string) (prSubject, error)
- type RemoteReview
- type Reviewer
- func (rv *Reviewer) Ack(ctx context.Context, r RemoteReview) (string, error)
- func (rv *Reviewer) AckTarget(ctx context.Context, id string) (RemoteReview, error)
- func (rv *Reviewer) Candidates(ctx context.Context) ([]RemoteReview, error)
- func (rv *Reviewer) Latest(ctx context.Context) (RemoteReview, error)
- func (rv *Reviewer) ManualHint() string
- func (rv *Reviewer) Pick(ctx context.Context) (RemoteReview, error)
- func (rv *Reviewer) Revision(r RemoteReview) string
- func (rv *Reviewer) Settle(ctx context.Context, r RemoteReview) (string, error)
- func (rv *Reviewer) SettleTarget(ctx context.Context, id, revision string) (RemoteReview, error)
- func (rv *Reviewer) Trigger(ctx context.Context) (string, string, time.Time, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoReview = errors.New("no review")
ErrNoReview is pick finding nothing to return: no review by the reviewer, or none left unhandled. wait keeps polling on it and nothing else.
var ErrReviewChanged = errors.New("the review changed since it was read")
ErrReviewChanged is settle refusing a review rewritten since it was read: a sticky comment edited by a re-review is a new, unread review.
Functions ¶
func BranchTask ¶
BranchTask is the task a PR's head branch belongs to: its link, else the id in its name; nil when neither names one the tracker resolves.
func CapturedHead ¶
CapturedHead is HEAD with the tracked work in the tree on top, as a commit no ref points at: `git stash create` touches neither the stash list nor the index, and prints nothing for a clean tree.
func LastPullOf ¶
LastPullOf is the newest request of any state whose head is branch, or 0; a checkout with no host CLI has none.
func MergedTree ¶
MergedTree is head merged in memory into the newer of base's local and origin refs, and that ref. Diffed against the ref it holds only what main lacks, which a merge base misses once the branch's earlier PR was squashed.
func OpenPullOf ¶
OpenPullOf is the newest open request whose head is branch, or 0: a merged or closed one is history, not the change's request. A checkout with no host CLI has no requests, and still diffs.
func OpenReviews ¶
func OpenReviews(ctx context.Context, t *target.Target, explicit string, warn io.Writer) (string, roundSeries, error)
OpenReviews is the findings directory review round and lore change both read, and what the branch says about its series. A branch checked out elsewhere, or a subject that does not resolve, gets no series read, so a closed one is archived only where its branch lives.
func PullNumberOf ¶
PullNumberOf is the request a token names, or 0: a url, #n, !n, or a bare number, always a request here; a task is named with its prefix or url.
func ResolvePRSubject ¶
ResolvePRSubject turns a PR, a task id or nothing (the current branch) into a subject, with the branch's open request looked up on the host, whose target then wins over the base git records.
Types ¶
type RemoteReview ¶
type RemoteReview struct {
ID string `json:"id"`
Kind string `json:"kind"`
URL string `json:"url"`
Author string `json:"author"`
Body string `json:"body"`
SHA string `json:"sha,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Done bool `json:"done"`
Handled bool `json:"handled"`
Settled bool `json:"settled"`
Stale bool `json:"stale"` // commits landed on the request after the sha it reviewed
// Triggerable says `f10 review trigger` can perform the declared trigger:
// the step offers a new review only when it is true.
Triggerable bool `json:"triggerable"`
Revision string `json:"revision"`
// Host is the review as the host keeps it, which every write goes back
// through; its Stored is the text an ack edits, since Body folds an
// inline review's comments in and writing that back would copy them
Host forge.Note `json:"-"`
}
A RemoteReview is one review normalized across the three arrival kinds and both CLIs; the exported fields are the --json output, the rest is for ack.
type Reviewer ¶
type Reviewer struct {
H hostops.Host
Facts facts.Review
// contains filtered or unexported fields
}
func NewReviewer ¶
func (*Reviewer) AckTarget ¶
AckTarget is the review id names, else pick's, else with every review handled the newest, which ack confirms rather than marks twice.
func (*Reviewer) Candidates ¶
func (rv *Reviewer) Candidates(ctx context.Context) ([]RemoteReview, error)
Candidates lists every review, newest update first. A settled one counts as handled: the settled marker is an edit, which would otherwise make the earlier handled reaction read as stale.
func (*Reviewer) Latest ¶
func (rv *Reviewer) Latest(ctx context.Context) (RemoteReview, error)
Latest is the newest review whatever its state: the one resolve reads.
func (*Reviewer) ManualHint ¶
func (*Reviewer) Pick ¶
func (rv *Reviewer) Pick(ctx context.Context) (RemoteReview, error)
Pick is the newest review the reviewer left that nobody handled yet.
func (*Reviewer) Revision ¶
func (rv *Reviewer) Revision(r RemoteReview) string
Revision fingerprints the text without f10's marks: a sticky comment rewritten by a re-review keeps its id and first sha, so only its text tells the new review apart.
func (*Reviewer) Settle ¶
Settle leaves the declared settled mark: resolve's word that every finding has a verdict.
func (*Reviewer) SettleTarget ¶
SettleTarget refuses a review now at another revision: a re-review rewrote it, and marking it would settle findings nobody read.