Documentation
¶
Overview ¶
Package profile composes the reviewer's guide from blocks: the loop's bundled ones, then the user's profile, each addressed by a path of the conditions under which it applies.
Index ¶
- Constants
- Variables
- func Apply(dir string, changes []Change, ...) error
- func BundledSHA(kind Kind) string
- func Conditions(p BlockPath, paths []string) string
- func Diff(c Change) string
- func DimsOf(intents *dintent.Registry, kind Kind) []string
- func NormalizeTag(kv string) (string, error)
- func PathOf(p BlockPath, intents *dintent.Registry) (string, error)
- type Addition
- type Block
- type BlockPath
- type Change
- type Cond
- type Dim
- type Facts
- type FrontMatter
- type FrontMatterError
- type Guide
- type Guides
- type Include
- type Kind
- type Layer
- type Listed
- type MissingError
- type Part
- type PathError
- type SizeError
- type Tree
Constants ¶
const ( Applies = "applies" NeedsBrief = "needs the brief" Trimmed = "dropped: over the judgment limit" Overridden = "replaced by an override" Depends = "depends on the pull request" Elsewhere = "not in this repository" )
const ( BlockMax = 16 << 10 JudgmentMax = 48 << 10 IncludeMax = 8 )
Variables ¶
var Dims = []Dim{DimOrganization, DimRepo, DimUser, DimTeam, DimAssociation, DimLabel, DimBase, DimRound, DimKind, DimSize, DimRisk}
Dims lists the dimensions in their canonical order.
Functions ¶
func Apply ¶
func Apply(dir string, changes []Change, backup func(path string, raw []byte) (string, error), intents *dintent.Registry, broken []dintent.Name) error
Apply writes changes to the layer at dir, then loads it; when it no longer loads, every file gets its previous bytes back and the load error is returned. backup, when not nil, keeps a copy of each file it overwrites or renames.
func BundledSHA ¶
BundledSHA hashes the bundled guide of kind, to tell when a new version changed a guide a profile replaces.
func Conditions ¶
Conditions says in words when a block of p applies, with the paths its front matter asks for.
func DimsOf ¶
DimsOf are the dimension conditions valid under kind: those its intent's manifest lists.
func NormalizeTag ¶
NormalizeTag reads a key=value tag as its one spelling, key:value.
Types ¶
type Addition ¶
type Addition struct {
Intents []Kind
Path BlockPath
// Section names the "## " heading the text goes under; "" appends at the end.
Section string
Title string
Override bool
Paths []string
Text string
}
Addition is a rule to put in the block of each of Intents at Path.
type Block ¶
type BlockPath ¶
BlockPath is where a block sits in a layer: its conditions in canonical order, its tags as key:value sorted, and its intent.
type Facts ¶
type Facts struct {
Owner, Repo, Author, Association, Base string
// Teams are the teams a review was requested through, as <org>-<slug>.
Teams, Labels []string
// Round is first or follow-up.
Round string
Kind, Size, Risk string
Tags, Files []string
HasBrief bool
}
Facts are what a block's conditions are matched against. Kind, Size, Risk, Tags (key:value) and Files come from the brief and count only when HasBrief is true.
type FrontMatter ¶
type FrontMatterError ¶
FrontMatterError carries Line and Col (1-based) when the problem has a position in the file.
func (FrontMatterError) Error ¶
func (e FrontMatterError) Error() string
type Guide ¶
type Guide struct {
Kind Kind
Parts []Part
// Delegates come from the last part that declares them.
Delegates map[string][]string
DelegatesFrom string
// Skipped lists, as "<layer>: <file>", the blocks that need a brief the
// pull request does not have.
Skipped []string
// Dropped lists the blocks left out to keep the judgment within JudgmentMax.
Dropped []string
}
type Guides ¶
Guides composes the guide of a pull request from a profile tree read once for the registry in force.
type Layer ¶
type Listed ¶
Listed is a block of the tree with its conditions in words and what it does for a pull request with given facts.
type MissingError ¶
type MissingError struct{ Layer, Dir string }
func (MissingError) Error ¶
func (e MissingError) Error() string
type Tree ¶
func Load ¶
Load reads and checks every block of the chain's layers, lowest layer first; intents are the registry blocks are written for, loaded first. Blocks of a broken intent are skipped, so its manifest's problems stay its own.
func (Tree) Compose ¶
Compose matches the blocks of kind against f and puts them in the text's order: depth first through the tree of paths, a node's own blocks (lower layer first) before its children by dimension rank and value, tags last. An override drops the blocks before it whose path is an ancestor of its own. Over JudgmentMax, blocks other than the root ones are dropped from the end.