Documentation
¶
Overview ¶
Package history reads anchors from the history of changes, through version control: the changes of a range with the capability each one's Capability trailer names and the sessions its Session trailers name, and checks the capabilities as design 07 section 5 asks. Every change names exactly one capability, and its slug is in the map as that change leaves it (a capability folder, or at a change from before the folders an old capability file), except changes made before the map, which serve no capability yet and get no finding, and prints a range's changes and findings as text or JSON. It reads history only through a vcs.Repo and never changes it.
Index ¶
- Constants
- func Sessions(message string) []string
- func SlugList(slugs []string) string
- func TrailerBlock(message string) [][2]string
- func Trailers(message, key string) []string
- func WriteChanges(w io.Writer, rng string, commits []Commit, findings []Finding, asJSON bool) error
- type Commit
- type Finding
Constants ¶
const ( KindMissing = "missing" // the commit has no Capability trailer KindMultiple = "multiple" // the commit names more than one capability KindUnknown = "unknown" // a trailer names a slug the map doesn't have )
Kinds of finding Check reports.
const CapabilitiesDir = ".physa/capabilities"
CapabilitiesDir is where the map keeps its capability folders (and, in the old layout, its capability files), relative to the repo's working directory.
Variables ¶
This section is empty.
Functions ¶
func Sessions ¶
Sessions returns the values of the Session trailers of a commit message, whether written as `Session: a, b` or on several lines, without duplicates, in the order written.
func TrailerBlock ¶
TrailerBlock returns every key and value of the message's trailers, in the order written, read the way Trailers reads them: from the last paragraph back, every paragraph made only of `Key: value` lines. Values are kept whole, never split on commas; a continuation line joins its value. A message with no trailers gives an empty list.
func Trailers ¶
Trailers returns the comma-split values of every trailer in a commit message whose key equals key, case-insensitively, in the order written. It reads trailers only, never the body: the subject paragraph never holds trailers; from the last paragraph back, every paragraph made only of `Key: value` lines does, so a squash merge's own trailers after a blank line read like the branch commit's. A line that continues a trailer joins its value.
func WriteChanges ¶
WriteChanges prints the changes of the range rng with their capability and the findings against the map, as one JSON object (range, commits, findings) when asJSON, and as text otherwise.
Types ¶
type Commit ¶
type Commit struct {
Hash string `json:"hash"`
Short string `json:"short"`
Subject string `json:"subject"`
Capabilities []string `json:"capabilities"`
Sessions []string `json:"sessions"`
}
Commit is one change of a range with the capabilities its trailers name. Capabilities holds the slugs of its Capability trailers in the order written; Sessions holds the ids of its Session trailers, without duplicates, in the order written.
type Finding ¶
type Finding struct {
Commit string `json:"commit"` // the commit's short hash
Kind string `json:"kind"`
Slug string `json:"slug,omitempty"`
Message string `json:"message"`
}
Finding is one problem with a commit's trailers.
func Check ¶
Check reports the trailer findings of commits. A change made before the map serves no capability yet, so a change whose parent leaves no map (no .physa/product/ folder and no old .physa/product.md, or no parent at all) gets no finding, and that covers the change that adds the map. A slug is known when its capability is in the map as that commit leaves it: its folder under .physa/capabilities/ holds a file, or, at a commit whose map has no .physa/product/ folder, an old <slug>.md file does. A commit that adds a capability may name it, and a slug only a later commit adds is unknown. A trailer value that is not a slug names nothing and is unknown. Findings follow commit order; for each commit, missing or multiple come before unknown slugs, each in the order written. The error is for a commit whose files version control cannot list.