branchmeta

package
v0.63.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 6 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 branchmeta is the record f10 keeps on a branch, as entries under `branch.<name>.` in the repository's local config: per branch, shared by every worktree, never pushed, and deleted with the branch.

Index

Constants

View Source
const (
	TriedFix   = "fix"
	TriedRerun = "rerun"
	// TriedLeft is the user's answer to leave a head red, or ship's note
	// that the default branch is red too, so no later read asks again
	TriedLeft = "left"
)

The actions a triage records.

View Source
const (
	FinishQueued  = "queued"
	FinishRunning = "running"
)

The states a DriveFinish records.

Variables

This section is empty.

Functions

func ClearOnGreen added in v0.60.0

func ClearOnGreen(ctx context.Context, dir, branch string, green bool) error

ClearOnGreen ends the red spell when the head read green. Every reader calls it, since a fix counts for the branch and a record left past green would spend the next spell's fix round.

func ClearTriage added in v0.60.0

func ClearTriage(ctx context.Context, dir, branch string) error

ClearTriage ends the red spell, once a head reads green.

func Dependents

func Dependents(records []Record, branch string) []string

Dependents are the branches whose AfterBranch is branch, in order.

func Get

func Get(ctx context.Context, dir, branch string, key Key) (string, error)

Get is one key on branch; absent is "" with no error.

func Out

func Out(ctx context.Context, dir, branch string, key Key) string

Out is Get with a failed read taken as no record, for the callers that treat an unreadable config the way gitx.Out does.

func RecordTriage added in v0.60.0

func RecordTriage(ctx context.Context, dir, branch, sha, action string) error

RecordTriage adds action on sha to branch's record, refusing one the record no longer allows.

func Set

func Set(ctx context.Context, dir, branch string, key Key, value string) error

Set writes one key on branch.

func SetBackend

func SetBackend(b Backend) func()

SetBackend swaps the store, for a test that answers records without git, and returns the function that puts the previous one back.

func Unset

func Unset(ctx context.Context, dir, branch string, key Key) error

Unset removes one key on branch, failing when it is absent.

func UnsetIfSet

func UnsetIfSet(ctx context.Context, dir, branch string, key Key) error

UnsetIfSet removes the key only where it is set, so an absent one is no error.

Types

type Backend

type Backend interface {
	Get(ctx context.Context, dir, branch string, key Key) (string, error)
	Set(ctx context.Context, dir, branch string, key Key, value string) error
	// Unset fails on an absent key, as git does.
	Unset(ctx context.Context, dir, branch string, key Key) error
	// All lists every known key on every branch, in the store's order.
	All(ctx context.Context, dir string) ([]Entry, error)
}

A Backend stores the records. Every read treats an absent key as "" with no error, as `git config --get` exits 1 for it.

type DriveFinish

type DriveFinish struct {
	State  string // FinishQueued or FinishRunning
	Action string // "" for none
}

A DriveFinish is the Finish key's value.

func ParseDriveFinish

func ParseDriveFinish(s string) (DriveFinish, bool)

ParseDriveFinish reads the Finish key's value; false for one that is empty or malformed.

func (DriveFinish) Format

func (d DriveFinish) Format() string

Format is the value the Finish key holds: `queued`, `running: merging #204`.

func (DriveFinish) Running

func (d DriveFinish) Running() bool

Running reports finish itself at work, not queued behind ship or a base.

type Entry

type Entry struct {
	Branch string
	Key    Key
	Value  string
}

An Entry is one listed key on one branch.

type Git

type Git struct{}

Git is the store in the repository's local config.

func (Git) All

func (Git) All(ctx context.Context, dir string) ([]Entry, error)

func (Git) Get

func (Git) Get(ctx context.Context, dir, branch string, key Key) (string, error)

func (Git) Set

func (Git) Set(ctx context.Context, dir, branch string, key Key, value string) error

func (Git) Unset

func (Git) Unset(ctx context.Context, dir, branch string, key Key) error

type Key

type Key string

A Key is one entry's name under the branch's section. The names are on disk in live checkouts, so they never change.

const (
	// Task links the branch to its task: a branch picked up from a PR need
	// not carry the id in its name, and a bundle's branch links its lead.
	Task Key = "f10-task"
	// Riders lists a bundle's riders, space-separated: the tasks one branch
	// ships beside its lead.
	Riders Key = "f10-tasks"

	// After and AfterBranch are the base task and its branch `f10 start
	// --after` records. Finish swaps them for Landed so the next step brings
	// the default branch in first.
	After       Key = "f10-after"
	AfterBranch Key = "f10-after-branch"
	Landed      Key = "f10-landed"
	// Moved is drive's note that the base's head moved past the branch, for
	// the next catchup, which clears it and Landed.
	Moved Key = "f10-base-moved"
	// Tip is the base commit the branch was last built on: a catchup rebases
	// onto from it once the base's history is rewritten.
	Tip Key = "f10-base-tip"

	// Agent is the whole profile (kind:model:effort) a start or drive gave
	// the branch's agent, read back on a rerun; absent for the kind's default.
	Agent Key = "f10-agent"
	// Finish is `f10 drive`'s record that it finishes the branch, and where
	// that finish stands. Whether the drive still runs is its task's lease,
	// never this: finish removes it with the branch, and a drive that stops
	// short sets it back to queued.
	Finish Key = "f10-finish"
	// Drive is the last skill drive saw the task finish: plan, ship or finish.
	Drive Key = "f10-drive"
	// Chain is the skills an older drive ran the task through, space-joined.
	// Drive no longer writes it, and removes one it finds.
	Chain Key = "f10-chain"
	// Flow and Pace are what a started task runs, for status and a rerun.
	Flow Key = "f10-flow"
	Pace Key = "f10-pace"
	// Watch is "false" once `f10 watch off` hands the task back.
	Watch Key = "f10-watch"
	// CI is what a triage of red checks tried during one red spell
	// (ci.go); any green read clears it.
	CI Key = "f10-ci"
)

func Split

func Split(name string) (string, Key, bool)

Split reads a full config name back into its branch and key. A key this binary does not know is not ok, so a newer binary's record breaks no read.

func (Key) For

func (k Key) For(branch string) string

For is the full config name of the key on branch, as git and its errors spell it.

type Record

type Record struct {
	Branch      string
	Task        string
	Riders      []string
	After       string
	AfterBranch string
	Landed      string
	Moved       string
	Tip         string
	Agent       string
	Finish      *DriveFinish // nil when absent or malformed
	Drive       string
	Flow        string
	Pace        string
	Watch       string
	CI          Triage
}

A Record is every key one branch holds, "" or nil where absent.

func Load

func Load(ctx context.Context, dir, branch string) (Record, error)

Load is branch's record.

func LoadAll

func LoadAll(ctx context.Context, dir string) ([]Record, error)

LoadAll is every branch's record in one read, ordered by each branch's first entry. It is a snapshot: a caller that writes and then looks up again loads again.

type Triage added in v0.60.0

type Triage struct {
	Tried []Tried
}

A Triage is the CI key's value: `<sha>:<action>` entries, space-joined. A fix counts for the branch, since it moves the head; a rerun counts for its sha, since the head stays.

func ParseTriage added in v0.60.0

func ParseTriage(s string) Triage

ParseTriage reads the CI key's value, skipping malformed entries.

func ReadTriage added in v0.60.0

func ReadTriage(ctx context.Context, dir, branch string) (Triage, error)

ReadTriage is branch's record; absent is empty.

func (Triage) Allows added in v0.60.0

func (t Triage) Allows(sha, action string) bool

Allows reports whether action may still be taken on sha.

func (Triage) Fixed added in v0.60.0

func (t Triage) Fixed() bool

Fixed reports a fix round already spent in this red spell.

func (Triage) Format added in v0.60.0

func (t Triage) Format() string

Format is the value the CI key holds.

func (Triage) Left added in v0.60.0

func (t Triage) Left(sha string) bool

Left reports sha left red on purpose.

func (Triage) Lines added in v0.60.0

func (t Triage) Lines() []string

Lines is the record for a reader, one action a line.

func (Triage) Rerun added in v0.60.0

func (t Triage) Rerun(sha string) bool

Rerun reports a rerun already spent on sha.

type Tried added in v0.60.0

type Tried struct {
	SHA, Action string
}

Tried is one recorded action on the head it was taken for.

Directories

Path Synopsis
Package branchmetatest answers branch records from memory, so a test sets and checks a record by branch and key instead of scripting git's argv.
Package branchmetatest answers branch records from memory, so a test sets and checks a record by branch and key instead of scripting git's argv.

Jump to

Keyboard shortcuts

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