Help us shape the future of Go! Take the 2026 Go Developer Survey

track

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package track implements the stackit track command for tracking branches in a stack.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Action

func Action(ctx context.Context, deps Deps, opts Options, handler Handler) error

Action performs the track operation

Types

type Deps added in v0.30.1

type Deps struct {
	Engine Engine
	Out    output.Output
	Here   actions.Here
}

Deps are the collaborators track needs. Adapters build them from their own runtime state; the action never sees bootstrap types.

type Engine added in v0.30.1

type Engine interface {
	actions.OwnershipEngine
	CurrentBranch(ctx context.Context) *engine.Branch
	Trunk() engine.Branch
	AllBranches() engine.Branches
	BranchNames() *engine.BranchSet
	GetRevision(ctx context.Context, branch engine.Branch) (string, error)
	BatchRevisions(ctx context.Context, branches engine.Branches) engine.RevisionMap
	GetMergeBase(ctx context.Context, rev1, rev2 string) (string, error)
	IsAncestor(ctx context.Context, ancestor, descendant string) (bool, error)
	FindMostRecentTrackedAncestors(ctx context.Context, branchName string) ([]string, error)
	TrackBranch(ctx context.Context, branchName string, parentBranchName string) error
	ConfigureRemoteMetadataSync(ctx context.Context) error
}

Engine lists exactly the engine methods track calls. The interactive parent picker (Handler.PromptSelectParent) brings its own collaborators from the adapter.

type Handler

type Handler interface {
	// PromptSelectParent prompts user to select a parent for the branch
	// Returns the selected parent branch name. The adapter supplies whatever
	// the picker needs (engine, GitHub client, logger) when building the handler.
	PromptSelectParent(ctx context.Context, branchName string) (string, error)

	// PromptTrackChild prompts user to confirm tracking a child branch
	// Returns true to track the child, false to skip
	PromptTrackChild(childName, parentName string) (bool, error)

	// Cleanup restores terminal state (may be no-op)
	Cleanup()

	// IsInteractive returns true if the handler supports interactive prompts
	IsInteractive() bool
}

Handler receives events from track action

type NullHandler

type NullHandler struct {
	handler.NullBase
}

NullHandler is a no-op handler for when nil is passed

func (*NullHandler) PromptSelectParent

func (h *NullHandler) PromptSelectParent(_ context.Context, _ string) (string, error)

PromptSelectParent implements Handler. Returns empty string for null handler.

func (*NullHandler) PromptTrackChild

func (h *NullHandler) PromptTrackChild(_, _ string) (bool, error)

PromptTrackChild implements Handler. Returns false for null handler.

type Options

type Options struct {
	BranchName string
	Force      bool
	Parent     string
}

Options contains options for the track command

Jump to

Keyboard shortcuts

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