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

init

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

Documentation

Overview

Package init provides functionality for initializing Stackit in a Git repository.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Action

func Action(ctx context.Context, repoRoot string, cfg Config, opts Options, handler Handler) error

Action performs the initialization of Stackit in a repository

func FindCommonlyNamedTrunk

func FindCommonlyNamedTrunk(branchNames []string) string

FindCommonlyNamedTrunk checks for common trunk branch names Returns the branch name if exactly one is found, empty string otherwise

func InferTrunk

func InferTrunk(ctx context.Context, runner git.Runner, branchNames []string) string

InferTrunk attempts to infer the trunk branch name

Types

type Config added in v0.29.0

type Config interface {
	IsInitialized() bool
	SetTrunk(trunk string) error
	UndoStackDepth() int
	LinearStacks() bool
}

Config is the repository configuration init reads and writes. The caller loads it (bootstrap/adapter) and passes it in; the action never loads config from disk itself.

type Handler

type Handler interface {
	// SelectTrunk prompts the user to select the trunk branch
	SelectTrunk(ctx context.Context, branchNames []string, inferredTrunk string) (string, error)

	// OnSuccess is called when initialization finishes
	OnSuccess(ctx context.Context, result Result)
}

Handler abstracts interaction for the init action

type Options

type Options struct {
	Trunk string
	Reset bool
}

Options contains options for the init action

type Result added in v0.29.0

type Result struct {
	// Trunk is the configured trunk branch.
	Trunk string
	// WasInitialized reports whether stackit was already initialized.
	WasInitialized bool
	// Reset reports whether all branches were untracked.
	Reset bool
}

Result describes a completed initialization.

Jump to

Keyboard shortcuts

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