ref

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package ref looks up which task a lookaround command is about. Every noun takes the same optional reference and falls back the same way, so the cascade lives here once: an explicit id, then the id in the current branch name, then the task this session's f10-state file records.

The prefix that makes a branch searchable comes from facts - the task id format a project declares, or the one its name derives. Without a prefix only an explicit reference is accepted, because 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. Reported so an error, or a caller that wants to say "GH-22, from the branch", can name it.

Variables

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

ErrNoReference means the cascade ran out. It is wrapped with what each tier actually had to offer, because "none found" alone sends a reader looking in the wrong place - most often at a session tier that was never available to them.

Functions

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 "".

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
}

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 empty explicit reference falls through to the branch and then to the session; a non-empty one that does not parse is an error rather than a fallthrough, because a typo'd id should say so instead of quietly opening whatever the branch happens to name.

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
}

A Ref is one looked-up task reference.

Jump to

Keyboard shortcuts

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