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 run state 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 ¶
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.
const RidersKey = "f10-tasks"
RidersKey is the key, beside TaskKey, that lists a bundle's riders, space-separated: the tasks one branch ships beside its lead.
const Separator = "+"
Separator joins a bundle's ids where they are typed and in its branch name: `ABC-1+ABC-2`, the lead first.
const TaskKey = "f10-task"
TaskKey is the local config key, under `branch.<name>.`, that links a branch to its task: start writes it on a branch picked up from a PR, whose name need not carry the id, and on a bundle's branch, for its lead.
Variables ¶
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 Match ¶ added in v0.33.0
Match is the task id in text: a branch name, a PR title, a commit subject. It is fromBranch minus git, so standup reads titles and subjects by the same rule and a test needs no checkout.
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 "".
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
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.
Any member of a bundle comes back with the whole bundle: a `+`-joined token as the lead, a single id as itself, so reading a rider still 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 every id of the bundle the task belongs to, lead first, or
// nil for a task that ships 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.