trace

package
v0.71.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 8 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 trace is the vocabulary of what f10 leaves on the host for a reader of the history: the git trailers a step's commit carries. Render and Parse sit side by side so the lines written are the lines read back; docs/traces.md is the spec, testdata/trailers its conformance suite.

Index

Constants

View Source
const (
	KeyTask   = "Task"
	KeyStep   = "Step"
	KeyReview = "Review"
)

The three trailer keys, version 1 of the spec.

View Source
const StateVersion = 1

StateVersion is the `v` every block written today carries; a block with another version reads as no state.

Variables

View Source
var (
	// ErrBadCount is a state count below zero.
	ErrBadCount = errors.New("trace: state counts are zero or more")
	// ErrBadAfter is a base task id with whitespace in it.
	ErrBadAfter = errors.New("trace: a base task id has no whitespace")
)
View Source
var (
	// ErrBadStep is a step name outside `[a-z][a-z0-9-]*`.
	ErrBadStep = errors.New("trace: a step is a lowercase token")
	// ErrBadTask is a task id with whitespace in it.
	ErrBadTask = errors.New("trace: a task id has no whitespace")
	// ErrBadReview is a review count below zero.
	ErrBadReview = errors.New("trace: review counts are zero or more")
)

Functions

func CarryState

func CarryState(body, from string) string

CarryState copies from's block into body byte for byte, where PutState would put one, so a body rewritten from scratch with traces off keeps the old block unrewritten.

func PutState

func PutState(body string, s State) (string, error)

PutState replaces the first block in place and removes any later one, else appends after a blank line; nothing else in the body changes.

func Render

func Render(t Trailers) (string, error)

Render writes the trailer lines in fixed order: every Task:, then Step:, then Review:, each newline-terminated. A zero value renders as "". It refuses a value Parse would not read back the same way.

func RenderState

func RenderState(s State) (string, error)

RenderState writes the block for s, one line, V forced to StateVersion. It refuses a value ParseState would not read back the same way.

func Rewrite

func Rewrite(body string, u Update) (string, error)

Rewrite is what a step does to a PR body: Merge over what it holds, put back.

func StripState

func StripState(body string) string

StripState removes every block, for a commit message built from a PR body: the block describes the PR, not the commit.

Types

type Parsed

type Parsed struct {
	Trailers

	Steps   []string `json:"steps,omitempty"`
	Reviews []Review `json:"reviews,omitempty"`
}

Parsed is what Parse reads out of a whole message: a squash merge concatenates commits, so every Step: and Review: line is kept in order, Step and Review being the last.

func Parse

func Parse(message string) Parsed

Parse reads every trailer line. Nothing is an error: history nobody controlled is still read, and no trailer parses to a zero value.

type Review

type Review struct {
	Round   int `json:"round"`
	Fixed   int `json:"fixed"`
	Skipped int `json:"skipped"`
}

Review is a resolve's fix commit in counts: the round it settled, and how many findings it fixed and skipped.

type State

type State struct {
	V      int      `json:"v"`
	Task   string   `json:"task,omitempty"`
	Riders []string `json:"riders,omitempty"`
	Step   string   `json:"step"`
	Round  int      `json:"round,omitempty"`
	Open   int      `json:"open,omitempty"`
	Asks   int      `json:"asks,omitempty"`
	After  string   `json:"after,omitempty"`
}

State is the hidden block a PR body carries: where the task stands, as the last step left it. Round, Open and Asks are a review's counts (findings awaiting a verdict, questions waiting on a person); the JSON key order is the struct's, which is the spec's.

func Merge

func Merge(prev State, u Update) State

Merge is the state a rewrite leaves: the update's fields, and each count from the update where passed, else from prev.

func ParseState

func ParseState(body string) (State, bool)

ParseState reads the first block a body holds. Anything unreadable (no block, bad JSON, another version, a count below zero) is no state, never an error: a body nobody controlled is still read.

type Trailers

type Trailers struct {
	Tasks  []string `json:"tasks,omitempty"`
	Step   string   `json:"step,omitempty"`
	Review *Review  `json:"review,omitempty"`
}

Trailers is what one commit message says about its task and step; Tasks lists a bundle lead first.

func (Trailers) Zero

func (t Trailers) Zero() bool

Zero reports a value with nothing to write.

type Update

type Update struct {
	Step   string
	Task   string
	Riders []string
	After  string
	Round  *int
	Open   *int
	Asks   *int
}

Update is what one rewrite changes. Step, Task, Riders and After are set every time; a count left nil keeps the value the block already holds, and a count set to zero clears it.

Jump to

Keyboard shortcuts

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