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

checkout

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: 10 Imported by: 0

Documentation

Overview

Package checkout implements the stackit checkout command: resolving a target branch, switching worktrees when the branch lives elsewhere, and checking it out.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Engine Engine
	Out    output.Output
	Log    output.Logger
	// Quiet skips the "already on" notice and the post-checkout branch info.
	Quiet bool
	Here  actions.Here
}

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

type Engine

type Engine interface {
	engine.BranchLookup
	Trunk() engine.Branch
	CurrentBranch(ctx context.Context) *engine.Branch
	AllBranches() engine.Branches
	BranchNames() *engine.BranchSet
	GetScope(branch engine.Branch) engine.Scope
	SortBranchesTopologically(ctx context.Context, branches engine.Branches) engine.Branches
	Graph(ctx context.Context, strategy engine.SortStrategy) *engine.StackGraph
	ReadBranchStatuses(ctx context.Context, branches engine.Branches) engine.BranchStatuses
	GetStackRootForBranch(branch engine.Branch) string
	GetWorktreeForStack(ctx context.Context, stackRoot string) (*engine.WorktreeInfo, error)
	CheckoutBranch(ctx context.Context, branch engine.Branch) error
}

Engine lists exactly the engine methods checkout calls.

type Handler

type Handler interface {
	// SelectBranch prompts the user to select a branch interactively.
	// Returns the selected branch name, or an error if selection failed or was canceled.
	SelectBranch(ctx context.Context, opts Options) (string, error)
}

Handler abstracts TTY vs non-TTY interactions for checkout operations

type NullHandler

type NullHandler struct{}

NullHandler is a no-op handler that returns an error for interactive operations

func (*NullHandler) SelectBranch

func (h *NullHandler) SelectBranch(context.Context, Options) (string, error)

SelectBranch returns an error since interactive selection is not available

type Options

type Options struct {
	BranchName         string // Optional: branch to checkout directly
	ShowUntracked      bool   // Include untracked branches in selection
	All                bool   // Show all branches across trunks
	StackOnly          bool   // Only show current stack (ancestors + descendants)
	CheckoutTrunk      bool   // Checkout trunk directly
	SkipWorktreeSwitch bool   // Skip worktree switch logic (for fallback checkout)
}

Options contains options for the checkout command

type Result

type Result struct {
	WorktreeSwitchPath string
	RerunArgs          []string
	FallbackTips       []string
	TargetBranch       string
}

Result represents the outcome of a checkout operation.

func Action

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

Action performs the checkout operation.

Jump to

Keyboard shortcuts

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