Documentation
¶
Overview ¶
Package index owns the branch→index mapping of a project's worktrees. The index feeds the port formula and the compose project name, so it must never change once a stack exists; this package allocates it once, records it in the registry, and recovers it from docker for worktrees that predate the recording.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoIndex = errors.New("no recorded index")
ErrNoIndex means the branch has no recorded index and no docker trace: as far as stacks are concerned, this worktree never started one.
Functions ¶
func MatchBranch ¶
MatchBranch finds the label belonging to this repo and branch among compose project labels. It extracts the candidate integer then rebuilds the canonical name, so stack.ProjectName stays the single naming authority.
Types ¶
type Mode ¶
type Mode int
Mode says whether a resolution may invent a new index. Commands that bring a stack up may; commands that address an existing stack (stop, remove, exec) must not, or they would "find" a stack that never existed.
type Resolver ¶
type Resolver struct {
ConfigPath string
Runner execx.Runner
Name string // project name in the registry
RepoName string // filepath.Base of the project directory
Out io.Writer
}
Resolver answers "which index does this branch own" for one project.
func (*Resolver) Resolve ¶
Resolve returns the branch's index. pos is the 1-based position git lists the worktree at (0 when unknown), used only as the historical fallback so worktrees created before indices were recorded keep the ports their .env already carries. Steps, first answer wins: recorded → backfill from docker labels → git position if free and clean → allocation (MayAllocate only).