ref

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: 14 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 ref looks up which task a lookaround command is about, one cascade for every noun: an explicit id, then the branch name, then this session's run state. Without a prefix from facts only an explicit reference is taken, since no rule can tell a task number in a branch name from any other number.

Index

Constants

View Source
const (
	OriginExplicit = "explicit"
	OriginBranch   = "branch"
	OriginSession  = "session"
)

Where a looked-up reference came from, so an error or a caller can name it.

View Source
const Separator = notation.Bundle

Separator joins a bundle's ids, `ABC-1+ABC-2`, lead first.

Variables

View Source
var ErrNoReference = errors.New("no task reference given")

ErrNoReference means the cascade ran out. It is wrapped with what each tier had to offer: "none found" alone sends a reader to the wrong tier, most often a session tier a human's prompt never had.

Functions

func BundleTitle added in v0.58.0

func BundleTitle(title string, r Ref) string

BundleTitle names a bundle's riders right after the lead id in title, because GitHub cuts long commit subjects from the end. A task alone keeps its title; a tag already there is replaced, so a refresh never doubles it.

func IsID added in v0.64.0

func IsID(word string) bool

IsID says whether word is shaped as a task id f10 start takes. That is `ABC-12` or a bare number with an optional -suffix, or a bundle of them joined by Separator. The shape is enough, because the API resolves each id against the project.

func JoinSuffix added in v0.67.0

func JoinSuffix(id, suffix string) string

JoinSuffix is SplitSuffix's inverse: id salted with suffix, as a command names one attempt of a task, or id alone with none.

func LeadsWith added in v0.65.0

func LeadsWith(title, id string) bool

LeadsWith reports whether title opens with id, in any case, after leading space.

func Match added in v0.33.0

func Match(prefix, text string) string

Match is the task id in text (a branch name, a PR title, a commit subject), anchored on a non-word boundary rather than the start since the id sits in any position and case (`feature/abc-123-fix-bug`).

func Matcher added in v0.40.0

func Matcher(prefix string) func(text string) string

Matcher is Match with the pattern compiled once, for a caller matching many texts against one prefix.

func Members added in v0.36.0

func Members(prefix, branch string) []string

Members is the bundle a branch name spells in its first segment, `ABC-1+ABC-2/slug`, lead first, or nil for a name that spells none.

func SplitSuffix

func SplitSuffix(token string) (string, string)

SplitSuffix separates a salted reference into the reference and its suffix. A token without one, or a url, comes back whole with "".

func TrimRiders added in v0.58.0

func TrimRiders(rest string) string

TrimRiders drops the riders tag that opens rest, the text after a lead id.

func TypedLead added in v0.58.0

func TypedLead(typed string) string

TypedLead is the first of TypedMembers.

func TypedMembers added in v0.58.0

func TypedMembers(typed string) []string

TypedMembers is each task a typed id names (`ft-1_v2+FT-2`), upper-cased with its suffix dropped, lead first: the key drives and leases use.

func WithoutRiders added in v0.65.0

func WithoutRiders(title, id string) string

WithoutRiders is title with the riders tag after its first id dropped, so a title f10 already wrote reads the same as its draft.

Types

type Lookup added in v0.26.0

type Lookup struct {
	Prefix string // id prefix from facts ("ABC", "GH"); empty where nothing declares or implies one
	Dir    string // checkout root - the branch is read from here
	// NoSession stops the cascade at the branch: a commit's trailer names the
	// branch's task or none, never one this session happens to have recorded
	NoSession bool
}

A Lookup answers references for one checkout.

func (Lookup) Find added in v0.26.0

func (r Lookup) Find(ctx context.Context, explicit string) (Ref, error)

Find walks the cascade. An explicit reference that does not parse is an error, not a fallthrough, since a typo'd id should say so instead of opening whatever the branch names; any bundle member comes back with the whole bundle, so reading a rider reads the rider and Head finds the branch.

type Ref

type Ref struct {
	ID     string // "GH-22": the prefix and number in the project's format
	Number string // "22": what a host CLI wants
	Origin string
	// Bundle is the bundle's every id, lead first; nil for a task shipping alone
	Bundle []string
}

A Ref is one looked-up task reference.

func (Ref) Head added in v0.36.0

func (r Ref) Head() Ref

Head is the reference a branch is looked up by: the bundle's lead, or the task itself. Plan, agent, run state and ledger all key on it.

func (Ref) Label added in v0.36.0

func (r Ref) Label() string

Label is the reference as typed at an entry point: `ABC-1+ABC-2`, or the id.

func (Ref) MemberRefs added in v0.36.0

func (r Ref) MemberRefs() []Ref

MemberRefs is every member as a reference of its own, the lead first.

func (Ref) Members added in v0.36.0

func (r Ref) Members() []string

Members is every id the reference ships: the bundle, or the task alone.

func (Ref) Riders added in v0.36.0

func (r Ref) Riders() []string

Riders is the bundle's ids after its lead, or nil.

Jump to

Keyboard shortcuts

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