Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContentHashes ¶ added in v0.5.0
ContentHashes returns each changed file's current content identity — its working-tree blob hash, or the deletion sentinel — keyed by path. Reviewed marks compare against these so a mark resets when the content changes.
Types ¶
type DiffScope ¶
type DiffScope struct {
Staged bool
Base string // "" for a working-tree diff
Target string // "" for a working-tree diff; a ref for a committed diff
Paths []string // optional pathspec filter (from `-- path...`)
}
DiffScope selects the diff the tests are read from: a working-tree change (optionally the staged side), or a committed range Base..Target.
type Extractor ¶
Extractor pulls test declarations out of a file's source. Each implementation uses whatever parser fits its language best (go/ast for Go, tree-sitter for the rest); the diff-correlation layer above treats them uniformly.
type RawSpec ¶
type RawSpec struct {
Path []string // describe/context nesting, outermost first
Name string
StartLine int
EndLine int
}
RawSpec is a test declaration found in a single file, before it's correlated with the diff. Lines are 1-based and refer to the parsed (new-side) content.
type Reviewed ¶ added in v0.5.0
type Reviewed struct {
// contains filtered or unexported fields
}
Reviewed tracks which working-tree files the user has marked reviewed, keyed by the blob hash of the content at the moment they marked it. A mark therefore resets the instant the file changes (the current hash no longer matches), and re-applies if the file is reverted to a state that was already reviewed.
func LoadReviewed ¶ added in v0.5.0
LoadReviewed reads the persisted marks for the repo, or an empty set if there are none / the file is unreadable.
func (*Reviewed) Count ¶ added in v0.5.0
Count returns how many of the given path→hash pairs are currently reviewed.
func (*Reviewed) IsReviewed ¶ added in v0.5.0
IsReviewed reports whether path is marked reviewed at its current blob hash.
func (*Reviewed) Toggle ¶ added in v0.5.0
Toggle flips path's reviewed mark at the given hash and persists, returning the new state. A file with no content hash (e.g. a deletion) can't be marked.
func (*Reviewed) Unreviewed ¶ added in v0.5.0
func (r *Reviewed) Unreviewed(files []git.ChangedFile, hashes map[string]string) []git.ChangedFile
Unreviewed returns the files whose current content isn't marked reviewed, given their content hashes (see ContentHashes).
type Spec ¶
type Spec struct {
File string `json:"file"`
Language string `json:"language"`
Path []string `json:"path,omitempty"`
Name string `json:"name"`
Line int `json:"line"`
Status string `json:"status"` // "added" | "renamed" | "modified"
Ticket string `json:"ticket,omitempty"`
}
Spec is a single test case touched by the diff under review: its name, the describe/context path that contains it, and how the diff changed it.
func Collect ¶
Collect extracts the test cases the diff touches, correlating each file's parsed specs with the lines the diff changed.
func (Spec) Glyph ¶
Glyph is the tests lens's own one-character change-kind marker: + a wholly new test, → a renamed test (its name changed), ~ a test whose body changed under an unchanged name (the last being the one a reviewer most wants to scrutinise, since an agent can quietly weaken an assertion there). It deliberately doesn't reuse git's file-status letters (A/R/M): a spec is a test case, not a file, and the same diff can mark a file Modified while a test inside it is new.
func (Spec) PathPrefix ¶
PathPrefix is the spec's describe/context nesting rendered as a "a › b › " prefix (empty when there's no nesting), so a renderer can place it before the name.