Documentation
¶
Overview ¶
Package baseline guards the integrity of a baseline folder: manifest.json holds the SHA-256 of every file and the hash of the last line of the acceptance log, whose lines are chained by the hash of the line before. A baseline changes only through driftgate (first run, import, accept); verify finds any other change.
The manifest is not a signature: anyone can recompute it. It makes a hand edit visible (verify fails, compare refuses), and a legitimate change then shows in the pull request as a new acceptance line next to the files.
Index ¶
- Constants
- Variables
- func Append(dir string, a Acceptance) error
- func Digest(dir string) (string, error)
- func SetDigest(dir string) (string, error)
- func Stamp(dir string) (string, error)
- func Sums(dir string) (map[string]string, error)
- func Write(dir string) error
- func WriteFrom(dir string, written map[string]string) error
- type Acceptance
- type LogState
- type Manifest
- type Result
Constants ¶
const ( ManifestFile = "manifest.json" LogFile = "acceptances.jsonl" )
File names inside a baseline folder.
const Version = 1
Variables ¶
var ErrNoManifest = errors.New("no " + ManifestFile)
ErrNoManifest means the baseline has no manifest.json (made before manifests existed, or the file was removed).
Functions ¶
func Append ¶
func Append(dir string, a Acceptance) error
Append adds an acceptance as the last line of the log, chained to the line before. The manifest is not rewritten; call Write after.
func Digest ¶
Digest identifies the current content of a baseline: the SHA-256 of its manifest. It is meaningful only for a baseline that verifies.
func SetDigest ¶
SetDigest identifies the content of a capture: its records and meta.json. Bodies are named by their hash (or ref) in the records, so the records cover them, and are not read.
func Stamp ¶
Stamp identifies the state of the files under dir without reading them: the path, size, modification time and mode of each. A baseline whose stamp is the one it had when it verified has not been written since.
func Sums ¶
Sums returns the SHA-256 of every file under dir by slash path, without the manifest and the log.
Types ¶
type Acceptance ¶
type Acceptance struct {
Version int `json:"version"`
At string `json:"at"`
By string `json:"by"`
Reason string `json:"reason"`
Ref string `json:"ref,omitempty"`
Requests []string `json:"requests"`
Signatures []string `json:"signatures"`
Capture string `json:"capture"`
Commit string `json:"commit,omitempty"`
// Prev is the SHA-256 of the line before (empty on the first line), so
// an edited, removed or inserted line breaks the chain.
Prev string `json:"prev,omitempty"`
}
Acceptance is one line of acceptances.jsonl.
type LogState ¶
LogState pins the acceptance log: its number of lines and the SHA-256 of the last one (empty when there are none).
type Manifest ¶
type Manifest struct {
Version int `json:"version"`
Files map[string]string `json:"files"` // slash path → SHA-256; without the manifest and the log
Log LogState `json:"acceptances"`
}
Manifest is manifest.json.
type Result ¶
type Result struct {
Files int // files listed in the manifest
Acceptances int // lines in the acceptance log
Problems []string // empty when the baseline is intact
// LineEndings: some changed files differ only in their line endings
// (CRLF where the manifest has LF): git converted them on checkout
// (core.autocrlf, on by default with Git for Windows).
LineEndings bool
}
Result is what Verify found.