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

state

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

Documentation

Overview

Package state implements the state command, a single machine-readable snapshot of the stack, working tree, and any in-progress operation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Action

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

Action prints a complete snapshot of the stack and working tree.

Types

type Deps

type Deps struct {
	Engine Engine
	Out    output.Output
	// GitHub supplies PR/CI status for the stack section. May be nil.
	GitHub github.Client
	// RepoRoot locates the continuation file that marks a halted stackit
	// operation.
	RepoRoot string
}

Deps are the collaborators state needs.

type Engine

type Engine = engine.Engine

Engine is the full engine: the stack section is built by actions.BuildTreeJSON, which takes an engine.Engine.

type OperationStatus

type OperationStatus struct {
	// Kind is "none", "rebase", or "merge".
	Kind string `json:"kind"`
	// InProgress is true when a rebase or merge is mid-flight.
	InProgress bool `json:"in_progress"`
	// StackitHalted is true when a `stackit continue` is pending (a stackit
	// operation was interrupted by a conflict).
	StackitHalted bool `json:"stackit_halted"`
	// ConflictedFiles lists unmerged paths (always present, possibly empty).
	ConflictedFiles []string `json:"conflicted_files"`
}

OperationStatus reports an in-progress git/stackit operation and its conflicts.

type Options

type Options struct {
	JSON bool
}

Options configures the state command.

type Result

type Result struct {
	CurrentBranch string                 `json:"current_branch"` // "" when detached
	Detached      bool                   `json:"detached"`
	Trunk         string                 `json:"trunk"`
	WorkingTree   WorkingTreeStatus      `json:"working_tree"`
	Operation     OperationStatus        `json:"operation"`
	Stack         actions.TreeJSONResult `json:"stack"`
}

Result is a complete machine-readable snapshot of the repository's stack, working tree, and any in-progress operation. Agents read this single result instead of fanning out across separate branch/git-status/log/info calls, and it removes brittle scraping of `.git` for conflict state.

func Build

func Build(ctx context.Context, deps Deps) Result

Build gathers the snapshot without printing it.

type WorkingTreeStatus

type WorkingTreeStatus struct {
	Clean     bool `json:"clean"`
	Staged    bool `json:"staged"`
	Unstaged  bool `json:"unstaged"`
	Untracked bool `json:"untracked"`
}

WorkingTreeStatus reports the staged/unstaged/untracked state of the worktree.

Jump to

Keyboard shortcuts

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