history

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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

func Sessions(message string) []string

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 SlugList

func SlugList(slugs []string) string

SlugList joins slugs for display, or gives a dash when there are none.

func TrailerBlock

func TrailerBlock(message string) [][2]string

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

func Trailers(message, key string) []string

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

func WriteChanges(w io.Writer, rng string, commits []Commit, findings []Finding, asJSON bool) error

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.

func Read

func Read(repo vcs.Repo, rng string) ([]Commit, error)

Read returns the non-merge changes of the range rng, newest first, each with the capabilities its trailers name. The adapter's own message is the error when the range is not valid.

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

func Check(repo vcs.Repo, commits []Commit) ([]Finding, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL