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
- Variables
- func BundleTitle(title string, r Ref) string
- func IsID(word string) bool
- func JoinSuffix(id, suffix string) string
- func LeadsWith(title, id string) bool
- func Match(prefix, text string) string
- func Matcher(prefix string) func(text string) string
- func Members(prefix, branch string) []string
- func SplitSuffix(token string) (string, string)
- func TrimRiders(rest string) string
- func TypedLead(typed string) string
- func TypedMembers(typed string) []string
- func WithoutRiders(title, id string) string
- type Lookup
- type Ref
Constants ¶
const ( OriginExplicit = "explicit" OriginBranch = "branch" OriginSession = "session" )
Where a looked-up reference came from, so an error or a caller can name it.
const Separator = "+"
Separator joins a bundle's ids, `ABC-1+ABC-2`, lead first.
Variables ¶
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
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
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
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
LeadsWith reports whether title opens with id, in any case, after leading space.
func Match ¶ added in v0.33.0
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
Matcher is Match with the pattern compiled once, for a caller matching many texts against one prefix.
func Members ¶ added in v0.36.0
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 ¶
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
TrimRiders drops the riders tag that opens rest, the text after a lead id.
func TypedMembers ¶ added in v0.58.0
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
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
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
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
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
MemberRefs is every member as a reference of its own, the lead first.