review

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContentHashes added in v0.5.0

func ContentHashes(repo *git.Repo, files []git.ChangedFile) map[string]string

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.

func (DiffScope) Committed

func (s DiffScope) Committed() bool

Committed reports whether the scope is a committed range rather than a working-tree (or staged) diff.

type Extractor

type Extractor interface {
	Language() string
	Extract(src []byte) []RawSpec
}

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

func LoadReviewed(repo *git.Repo) *Reviewed

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

func (r *Reviewed) Count(hashes map[string]string) int

Count returns how many of the given path→hash pairs are currently reviewed.

func (*Reviewed) IsReviewed added in v0.5.0

func (r *Reviewed) IsReviewed(path, currentHash string) bool

IsReviewed reports whether path is marked reviewed at its current blob hash.

func (*Reviewed) Toggle added in v0.5.0

func (r *Reviewed) Toggle(path, currentHash string) bool

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

func Collect(repo *git.Repo, scope DiffScope) ([]Spec, error)

Collect extracts the test cases the diff touches, correlating each file's parsed specs with the lines the diff changed.

func (Spec) Glyph

func (s Spec) Glyph() string

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

func (s Spec) PathPrefix() string

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.

Jump to

Keyboard shortcuts

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