Documentation
¶
Overview ¶
Package reviewgroups keeps review groups: named sets of open pull requests of one repository that a person reviews together, and the versions of their combined review. See README.md.
Index ¶
- Constants
- Variables
- func MembersFile(members []MemberReview) ([]byte, error)
- func Outdated(members []int, reviewed []ReviewedMember, heads map[int]string) bool
- type API
- type Group
- type InvalidError
- type LandedMember
- type MemberReview
- type Publisher
- func (Publisher) BeginRun(context.Context, store.Key, time.Time) (int64, error)
- func (Publisher) FinishRun(context.Context, int64, string) error
- func (Publisher) HeartbeatRun(context.Context, int64, time.Time) error
- func (p Publisher) Latest(ctx context.Context, _ store.Key) (store.Version, error)
- func (p Publisher) Put(ctx context.Context, _ store.Key, previous, next store.Version) error
- type Registry
- type ReviewedMember
- type Store
- func (s *Store) Close() error
- func (s *Store) Create(ctx context.Context, repository, name string, members []int) (Group, error)
- func (s *Store) Delete(ctx context.Context, id string) error
- func (s *Store) Get(ctx context.Context, id string) (Group, error)
- func (s *Store) Latest(ctx context.Context, id string) (store.Version, error)
- func (s *Store) List(ctx context.Context) ([]Group, error)
- func (s *Store) Put(ctx context.Context, id string, previous int, v store.Version) error
- func (s *Store) Summary(ctx context.Context, id string) (Summary, error)
- func (s *Store) SyncStacks(ctx context.Context, repository string, prs []discovery.PullRequest, ...) (bool, error)
- func (s *Store) Update(ctx context.Context, id string, name *string, members []int) (Group, error)
- func (s *Store) Version(ctx context.Context, id string, version int) (store.Version, error)
- func (s *Store) Versions(ctx context.Context, id string) ([]store.Metadata, error)
- type Summary
- type View
Constants ¶
const ( StateMerged = "merged" StateClosed = "closed" StateUnknown = "unknown" )
The states of a member that is no longer open (chainEntry.State).
const ( MinMembers = 2 MaxMembers = 8 // MaxNameLength is the schema's bound on a stack title, which the // group's name becomes. MaxNameLength = 80 )
MaxMembers bounds a group's pull requests; MinMembers is the fewest a group keeps, since one pull request is reviewed on its own.
const ( CodeInvalid = "invalid_group" CodeCrossRepository = "cross_repository" CodeNotPicked = "not_picked" )
The codes of InvalidError.
Variables ¶
var ErrConflict = errors.New("the group review changed during the operation; generate again")
ErrConflict is a version that another generation published first.
var ErrNotFound = errors.New("review group not found")
ErrNotFound is a group that does not exist or was deleted.
Functions ¶
func MembersFile ¶
func MembersFile(members []MemberReview) ([]byte, error)
MembersFile is members.json, the members' saved reviews in brief for the group run: each member's title, the head the run reviews, and its review's summary, current sections and active risks. Stale sections and mitigated risks are left out, and so is what does not fit a member's share.
func Outdated ¶
func Outdated(members []int, reviewed []ReviewedMember, heads map[int]string) bool
Outdated reports whether a group review that covered reviewed no longer matches the group: its members changed, or a member's current head (from discovery; an unknown head is not counted) differs from the head reviewed. A group without a review is not outdated.
Types ¶
type API ¶
type API struct {
Store *Store
Registry Registry
// Index is the review index, for the members' current heads; nil leaves
// every head unknown, so no group reads as outdated.
Index func(context.Context) (reviewindex.Snapshot, error)
// Changed is called after every mutation.
Changed func()
// Patch reads one file's patch; nil uses a locallink.Patcher.
Patch func(context.Context, locallink.PatchRequest) (locallink.PatchResult, error)
// File reads one file at a commit; nil uses locallink.ReadFile.
File func(context.Context, locallink.FileRequest) (locallink.FileResult, error)
// contains filtered or unexported fields
}
API serves /api/groups. It has no authentication; the daemon mounts it behind its authenticated host.
type Group ¶
type Group struct {
ID string `json:"id"`
// Repository is the registry's identity of the members' repository:
// lowercase owner/name, or host/owner/name off github.com.
Repository string `json:"repository"`
Name string `json:"name"`
// Members are the pull request numbers, ascending.
Members []int `json:"members"`
// Stack marks a group baum made for a stack of pull requests and keeps
// in step with it (SyncStacks); a person's rename or member change makes
// it theirs.
Stack bool `json:"stack"`
// Landed are the members of a stack group that are no longer open,
// ascending, with what became of them. They stay in the stack, in
// place, but are not Members: a review never reads them. Empty for a
// group a person made.
Landed []LandedMember `json:"landed"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// contains filtered or unexported fields
}
Group is one review group's definition.
type InvalidError ¶
InvalidError is a group definition the rules refuse; Code is the machine-readable reason the API answers with.
func (*InvalidError) Error ¶
func (e *InvalidError) Error() string
type LandedMember ¶
LandedMember is a stack group member that is no longer open. State is StateMerged, StateClosed or StateUnknown (not open any more, but discovery has not yet seen whether it merged).
type MemberReview ¶
type MemberReview struct {
Number int
// Head is the member's head the group run reviews.
Head string
// Version and Document are the member's latest saved review.
Version int
Document []byte
}
MemberReview is one member's saved review, as a group run reads it.
type Publisher ¶
Publisher is the group as generate.Publish's version store: it ignores the pull request key and records no run leases (the job queue shows a running group job).
func (Publisher) HeartbeatRun ¶
HeartbeatRun implements generate.Versions.
type Registry ¶
type Registry interface {
Repositories(context.Context) ([]repos.Repository, error)
}
Registry is the part of *repos.Registry the handler reads: the picked repositories and their clones.
type ReviewedMember ¶
type ReviewedMember struct {
Number int `json:"number"`
HeadSHA string `json:"head_sha"`
ReviewVersion int `json:"review_version"`
}
ReviewedMember is a member as a group review version covered it: the document's stack member.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store keeps group definitions and versions in the application database.
func (*Store) Delete ¶
Delete removes the group from every list. Its versions stay in the store, and the members' own reviews are never touched. A deleted stack group keeps its flag, so SyncStacks makes no new group for its pull requests.
func (*Store) Latest ¶
Latest returns the group's latest version, store.ErrNotFound when it has none.
func (*Store) Put ¶
Put appends v only while previous is still the group's latest version (0 for none). The document must be the group's: a review of its repository with a stack, at version previous+1. A stack group, whose name is baum's, takes the name the review gave it (the document's stack title); a group the person made or took over keeps theirs.
func (*Store) SyncStacks ¶
func (s *Store) SyncStacks(ctx context.Context, repository string, prs []discovery.PullRequest, observations []discovery.Observation) (bool, error)
SyncStacks keeps repository's stack groups in step with the stacks among its pull requests (package stacks, the hosted detection) and reports whether anything changed. prs are the open pull requests and observations what discovery knows of others (a merged or closed state):
- a stack of 2 to MaxMembers open pull requests without a group gets a new stack group;
- a stack group whose stack gained or lost members gets the stack's members;
- a member that merged or closed stays in the group in its place, as Landed with its state, and is no longer a Member. A member discovery no longer lists and has no observation of is kept as StateUnknown until its state is known;
- a stack group whose stack is gone (no open member left, unstacked, or grown past MaxMembers open pull requests) is dissolved: removed from every list, its versions kept.
The person's choices win: a pull request in a group the person made or took over, or in a stack group the person deleted, takes no part.
func (*Store) Update ¶
Update renames the group when name is not nil and replaces its members when members is not nil. Either makes a stack group the person's own.
type Summary ¶
type Summary struct {
VersionCount int `json:"version_count"`
Latest *store.Metadata `json:"latest"`
// RiskScore is the latest version's summary.risk_score, or null.
RiskScore json.RawMessage `json:"risk_score"`
Reviewed []ReviewedMember `json:"reviewed"`
}
Summary is what the group list shows of a group's versions.