actions

package
v0.17.15 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Package actions provides high-level business logic for CLI commands.

Each action corresponds to a stackit command (create, submit, sync, etc.) and orchestrates operations across the engine, git, and github packages.

Key patterns:

  • Actions accept runtime.Context which provides Engine, Splog, and other dependencies
  • Actions are stateless - all state is managed through the Engine interface
  • Actions handle user interaction through the tui package

Dependencies:

  • engine: Core branch state management
  • git: Low-level git operations
  • tui: User interface and prompts

Index

Constants

View Source
const (
	LogStyleNormal = "NORMAL"
	LogStyleFull   = "FULL"
	LogStyleShort  = "SHORT"
)

LogStyle defines the output style for the log command

Variables

This section is empty.

Functions

func ConfigListAction

func ConfigListAction(repoRoot string, writer io.Writer) error

ConfigListAction prints all configuration values in a formatted way

func ContinueAction

func ContinueAction(ctx *app.Context, opts ContinueOptions) error

ContinueAction performs the continue operation

func DebugAction

func DebugAction(ctx *app.Context, opts DebugOptions) error

DebugAction collects and outputs debugging information

func EnterConflictWorkflow

func EnterConflictWorkflow(ctx *app.Context, firstConflict string, allBranches []engine.Branch) error

EnterConflictWorkflow performs the rebase to enter conflict state and persists continuation state. This helper is shared between RestackBranchesWithHandler (standalone mode) and sync.RunSync (sync mode).

func FormatRerereResolved

func FormatRerereResolved(count int) string

FormatRerereResolved renders the standard message describing how many rebase conflicts git rerere auto-resolved during an operation.

func FreezeAction

func FreezeAction(ctx *app.Context, branchName string) error

FreezeAction freezes the specified branch and all branches downstack of it (recursive parents)

func GetAction

func GetAction(ctx *app.Context, branchOrPR string, opts GetOptions, handler GetHandler) error

GetAction performs the get operation

func InfoAction

func InfoAction(ctx *app.Context, opts InfoOptions) error

InfoAction displays information about a branch or the entire stack

func LogAction

func LogAction(ctx *app.Context, opts LogOptions) error

LogAction displays the branch tree

func ModifyAction

func ModifyAction(ctx *app.Context, opts ModifyOptions) error

ModifyAction performs the modify operation

func NewSnapshot

func NewSnapshot(command string, options ...SnapshotOption) engine.SnapshotOptions

NewSnapshot creates a new SnapshotOptions with the given command and options

func PluralIt

func PluralIt(plural bool) string

PluralIt returns "them" if plural is true, otherwise "it"

func PluralSuffix

func PluralSuffix(word string, plural bool) string

PluralSuffix returns the appropriate plural suffix for the given word if plural is true, otherwise empty string

func Pluralize

func Pluralize(word string, count int) string

Pluralize returns the plural form of word if count != 1, otherwise returns the singular form

func PopAction

func PopAction(ctx *app.Context, _ PopOptions) error

PopAction deletes the current branch but retains the state of files in the working tree

func PrintConflictStatus

func PrintConflictStatus(ctx *app.Context, branchName string) error

PrintConflictStatus displays conflict information and instructions to the user. Assumes a rebase is in progress: HEAD-side markers reflect the parent/base and the ">>>>>>>" side reflects the branch being replayed. Both call sites (EnterConflictWorkflow and ContinueAction) operate during rebase.

func PushMetadataAndSyncPRs

func PushMetadataAndSyncPRs(ctx *app.Context, branchNames []string) error

PushMetadataAndSyncPRs pushes metadata for the given branches to remote and updates their PRs on GitHub

func PushMetadataOnly

func PushMetadataOnly(ctx *app.Context, eng MetadataPushEngine, branchNames []string) error

PushMetadataOnly pushes metadata refs without updating GitHub PRs. Use this when you want to push metadata changes but defer PR updates to sync.

func RenameAction

func RenameAction(ctx *app.Context, opts RenameOptions) error

RenameAction renames the current branch and updates metadata

func ReorderAction

func ReorderAction(ctx *app.Context) error

ReorderAction performs the reorder operation

func ResolveBranch

func ResolveBranch(eng engine.BranchReader, branchName string) (engine.Branch, error)

ResolveBranch resolves a branch name to a Branch, defaulting to current branch if empty. Returns errors.ErrNotOnBranchNoBranchSpecified if no branch specified and not on a branch.

func ResolveBranchName

func ResolveBranchName(eng engine.BranchReader, branchName string) (string, error)

ResolveBranchName resolves a branch name, defaulting to current branch if empty. Returns errors.ErrNotOnBranchNoBranchSpecified if no branch specified and not on a branch.

func RestackAction

func RestackAction(ctx *app.Context, plan *RestackPlan, handler handlers.RestackHandler) error

RestackAction performs the restack operation using a pre-computed plan. Build the plan via PlanRestack — callers are expected to use the plan to gate UX decisions (e.g. whether to start a TUI), so requiring it here keeps the two phases consistent.

func RestackBranches

func RestackBranches(ctx *app.Context, branches []engine.Branch) error

RestackBranches restacks a list of branches using the engine's batch restack method

func RestackBranchesWithHandler

func RestackBranchesWithHandler(ctx *app.Context, branches []engine.Branch, callback RestackProgressCallback, mode ConflictMode) error

RestackBranchesWithHandler restacks branches with optional progress callback. See ConflictMode for how mode controls conflict handling.

func SquashAction

func SquashAction(ctx *app.Context, opts SquashOptions) error

SquashAction performs the squash operation

func StackInfoAction

func StackInfoAction(ctx *app.Context, opts StackInfoOptions) error

StackInfoAction retrieves information about branches in the current stack

func TakeBestEffortSnapshot

func TakeBestEffortSnapshot(ctx *app.Context, opts engine.SnapshotOptions)

TakeBestEffortSnapshot records an undo snapshot and logs failures without aborting the action.

func UnfreezeAction

func UnfreezeAction(ctx *app.Context, branchName string) error

UnfreezeAction unfreezes the specified branch and all branches upstack of it (recursive children)

func UpdateBranchPRMetadata

func UpdateBranchPRMetadata(ctx *app.Context, name string, repoOwner, repoName string)

UpdateBranchPRMetadata updates PR title and body footer for a single branch

func UpdateStackPRMetadata

func UpdateStackPRMetadata(ctx *app.Context, branches []string, repoOwner, repoName string)

UpdateStackPRMetadata updates PR titles and body footers for a list of branches

Types

type BranchDeletionPlan

type BranchDeletionPlan struct {
	// BranchesToDelete maps branch name to deletion reason
	BranchesToDelete map[string]string
	// BranchesWithNewParents lists branches that will be reparented
	BranchesWithNewParents []string
	// SkippedInWorktree lists branches skipped due to being in a worktree
	SkippedInWorktree []string
	// UtilityBranches tracks which branches in BranchesToDelete are utility branches
	// (e.g., consolidated merge branches). These can be auto-confirmed for deletion
	// when their associated PR is closed/merged.
	UtilityBranches map[string]bool
	// UnpushedBranches tracks which branches in BranchesToDelete have unpushed local changes
	// (local branch is ahead of or diverged from remote)
	UnpushedBranches map[string]bool
	// contains filtered or unexported fields
}

BranchDeletionPlan contains the planned branch deletions before execution

func PlanBranchDeletions

func PlanBranchDeletions(ctx *app.Context, opts CleanBranchesOptions) (*BranchDeletionPlan, error)

PlanBranchDeletions identifies branches that should be deleted and builds a deletion plan. This does NOT execute any deletions - use ExecuteBranchDeletions to apply the plan.

type BranchInfo

type BranchInfo struct {
	Name           string         `json:"name"`
	SHA            string         `json:"sha,omitempty"`
	Parent         string         `json:"parent,omitempty"`
	ParentRevision string         `json:"parent_revision,omitempty"`
	Children       []string       `json:"children,omitempty"`
	IsTracked      bool           `json:"is_tracked"`
	IsFixed        bool           `json:"is_fixed"`
	IsTrunk        bool           `json:"is_trunk"`
	PRInfo         *engine.PrInfo `json:"pr_info,omitempty"`
	MetadataRefSHA string         `json:"metadata_ref_sha,omitempty"`
}

BranchInfo represents detailed information about a branch

type BranchName

type BranchName string

BranchName is a type alias for a git branch name

type CheckoutHandler

type CheckoutHandler 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 *app.Context, opts CheckoutOptions) (string, error)
}

CheckoutHandler abstracts TTY vs non-TTY interactions for checkout operations

type CheckoutOptions

type CheckoutOptions 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)
}

CheckoutOptions contains options for the checkout command

type CheckoutResult

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

CheckoutResult represents the outcome of a checkout operation.

func CheckoutAction

func CheckoutAction(ctx *app.Context, opts CheckoutOptions, handler CheckoutHandler) (CheckoutResult, error)

CheckoutAction performs the checkout operation.

type CleanBranchesOptions

type CleanBranchesOptions struct {
	Force             bool
	InManagedWorktree bool   // True if running from a stackit-managed worktree
	CurrentBranch     string // Name of the current branch (used to skip deletion in worktree)
}

CleanBranchesOptions contains options for cleaning branches

type CleanBranchesResult

type CleanBranchesResult struct {
	DeletedBranches        map[string]string // name -> reason
	BranchesWithNewParents []string
	SkippedInWorktree      []string // branches that couldn't be deleted from worktree
	SkippedUnpushed        []string // branches skipped due to unpushed local changes
}

CleanBranchesResult contains the result of cleaning branches

func CleanBranches

func CleanBranches(ctx *app.Context, opts CleanBranchesOptions) (*CleanBranchesResult, error)

CleanBranches finds and deletes merged/closed branches. It follows a multi-phase approach: 1. Identify which branches SHOULD be deleted (parallel pre-calculation). 2. Build a deletion plan by traversing the stack (DFS). 3. Reparent branches that are NOT being deleted but whose parents ARE. 4. Execute the deletions in batches (greedy iterative approach).

func ExecuteBranchDeletions

func ExecuteBranchDeletions(ctx *app.Context, plannedDeletion *BranchDeletionPlan, branchesToDelete map[string]bool) (*CleanBranchesResult, error)

ExecuteBranchDeletions executes a previously planned deletion. The branchesToDelete parameter allows filtering which branches from the plan to actually delete. If nil, all planned branches are deleted.

type CommandSnapshot

type CommandSnapshot struct {
	Timestamp     time.Time `json:"timestamp"`
	Command       string    `json:"command"`
	Args          []string  `json:"args"`
	CurrentBranch string    `json:"current_branch"`
}

CommandSnapshot represents a single command from the undo history

type CommitSHA

type CommitSHA string

CommitSHA is a type alias for a git commit hash

type ConflictMode

type ConflictMode int

ConflictMode controls how RestackBranchesWithHandler responds to rebase conflicts.

const (
	// ConflictModeEnterWorkflow stops at the first conflict, writes rebase state
	// to the working tree, and expects the user to resolve it with stackit continue.
	// This is the standalone CLI default.
	ConflictModeEnterWorkflow ConflictMode = iota

	// ConflictModeContinue validates all branches first, restacks non-conflicting
	// ones, and reports conflicts through the progress callback without writing
	// rebase state. Use this in sync mode, parallel workers (rebase state would
	// be torn down with the worktree), and --continue-on-conflict flows.
	ConflictModeContinue
)

type ContinuationStateInfo

type ContinuationStateInfo struct {
	BranchesToRestack     []string `json:"branches_to_restack,omitempty"`
	BranchesToSync        []string `json:"branches_to_sync,omitempty"`
	CurrentBranchOverride string   `json:"current_branch_override,omitempty"`
	RebasedBranchBase     string   `json:"rebased_branch_base,omitempty"`
}

ContinuationStateInfo represents continuation state

type ContinueOptions

type ContinueOptions struct {
	AddAll bool
}

ContinueOptions contains options for the continue command

type DebugInfo

type DebugInfo struct {
	Timestamp           time.Time                `json:"timestamp"`
	RecentCommands      []CommandSnapshot        `json:"recent_commands"`
	StackState          StackStateInfo           `json:"stack_state"`
	ContinuationState   *ContinuationStateInfo   `json:"continuation_state,omitempty"`
	RepositoryInfo      RepositoryInfo           `json:"repository_info"`
	RemoteMetadataState *RemoteMetadataStateInfo `json:"remote_metadata_state,omitempty"`
}

DebugInfo represents the complete debugging information

type DebugOptions

type DebugOptions struct {
	Limit      int  // Limit number of recent commands to show (0 = all)
	ShowRemote bool // Fetch and show remote metadata state
}

DebugOptions contains options for the debug command

type DiffStats

type DiffStats struct {
	FilesChanged int `json:"files_changed"`
	Additions    int `json:"additions"`
	Deletions    int `json:"deletions"`
}

DiffStats represents summary diff information

type GetEvent

type GetEvent struct {
	Phase       GetPhase     // Current phase
	Type        GetEventType // Event type
	Branch      string       // Branch name (if applicable)
	PRNumber    *int         // PR number (if applicable)
	Message     string       // Human-readable description
	NewRevision string       // For position changes
	IsNew       bool         // Is this a new branch?
	Error       error        // If non-nil, this step had an error
}

GetEvent represents a progress update during get

type GetEventType

type GetEventType string

GetEventType represents the type of get event

const (
	GetEventStarted   GetEventType = "started"
	GetEventProgress  GetEventType = "progress"
	GetEventCompleted GetEventType = "completed"
	GetEventSkipped   GetEventType = "skipped"
)

Event types for get operations

type GetHandler

type GetHandler interface {
	// Start is called at the beginning of get with target info
	Start(targetBranch string, prNumber *int)

	// EmitEvent is called for each progress update
	EmitEvent(event GetEvent)

	// Complete is called when get finishes with the summary
	Complete(summary GetSummary)

	// RestackHandler methods are available for restack phase output
	// This ensures consistent restack output between get, sync, and restack commands
	handlers.RestackHandler
}

GetHandler abstracts TTY vs non-TTY output for get operations It embeds RestackHandler to provide consistent output for restack phase

type GetNullHandler

type GetNullHandler struct{}

GetNullHandler is a no-op handler for testing or when output is not needed

func (*GetNullHandler) Complete

func (h *GetNullHandler) Complete(_ GetSummary)

Complete implements GetHandler.

func (*GetNullHandler) EmitEvent

func (h *GetNullHandler) EmitEvent(_ GetEvent)

EmitEvent implements GetHandler.

func (*GetNullHandler) OnRestackBranch

func (h *GetNullHandler) OnRestackBranch(_ string, _ handlers.RestackResult, _ string, _ *int, _ engine.LockReason, _ bool, _ bool, _ string, _ bool, _, _ string, _ int)

OnRestackBranch implements RestackHandler.

func (*GetNullHandler) OnRestackComplete

func (h *GetNullHandler) OnRestackComplete(_, _ int, _ []string)

OnRestackComplete implements RestackHandler.

func (*GetNullHandler) OnRestackStart

func (h *GetNullHandler) OnRestackStart(_ int)

OnRestackStart implements RestackHandler.

func (*GetNullHandler) Start

func (h *GetNullHandler) Start(_ string, _ *int)

Start implements GetHandler.

type GetOptions

type GetOptions struct {
	Downstack bool // Don't sync upstack branches if branch exists locally
	Force     bool // Overwrite all fetched branches with remote source of truth
	Restack   bool // Restack after syncing (default true)
	Unfrozen  bool // Checkout new branches as unfrozen
}

GetOptions contains options for the get command

type GetPhase

type GetPhase string

GetPhase represents the current phase of the get operation

const (
	GetPhaseFetch    GetPhase = "fetch"    // Fetching branches from remote
	GetPhaseSync     GetPhase = "sync"     // Syncing branches (create/update)
	GetPhaseMetadata GetPhase = "metadata" // Fetching and applying metadata
	GetPhaseCheckout GetPhase = "checkout" // Checking out target branch
)

Phases of the get operation

type GetSummary

type GetSummary struct {
	TargetBranch    string // The branch that was retrieved
	BranchesCreated int    // Number of branches created
	BranchesUpdated int    // Number of branches updated
	Restacked       int    // Number of branches restacked
	IsFrozen        bool   // Was the target branch frozen?
	UpToDate        bool   // Everything was already current
}

GetSummary holds aggregate results from a get operation

type InfoOptions

type InfoOptions struct {
	BranchName string
	Body       bool
	Diff       bool
	Patch      bool
	Stat       bool
	Stack      bool
	JSON       bool
}

InfoOptions contains options for the info command

type LogBranchInfo

type LogBranchInfo struct {
	Name         string     `json:"name"`
	Parent       string     `json:"parent,omitempty"`
	IsCurrent    bool       `json:"is_current"`
	IsTrunk      bool       `json:"is_trunk"`
	IsLocked     bool       `json:"is_locked,omitempty"`
	IsFrozen     bool       `json:"is_frozen,omitempty"`
	NeedsRestack bool       `json:"needs_restack,omitempty"`
	Commits      int        `json:"commits"`
	Additions    int        `json:"additions,omitempty"`
	Deletions    int        `json:"deletions,omitempty"`
	PR           *LogPRInfo `json:"pr,omitempty"`
	Scope        string     `json:"scope,omitempty"`
	Children     []string   `json:"children,omitempty"`
}

LogBranchInfo represents a single branch in JSON output

type LogJSONResult

type LogJSONResult struct {
	Branches        []LogBranchInfo `json:"branches"`
	Summary         LogSummary      `json:"summary"`
	GitHubAvailable bool            `json:"github_available"`
}

LogJSONResult represents the JSON output for the log command

type LogOptions

type LogOptions struct {
	Style         string // LogStyleNormal, LogStyleFull, or LogStyleShort
	Steps         *int
	BranchName    string
	ShowUntracked bool
	Interactive   bool
	ShowSHAs      bool // Show commit SHAs next to branch names
	JSON          bool // Output in JSON format
}

LogOptions contains options for the log command

type LogPRInfo

type LogPRInfo struct {
	Number       int    `json:"number"`
	URL          string `json:"url,omitempty"`
	Title        string `json:"title,omitempty"`
	State        string `json:"state"`
	IsDraft      bool   `json:"is_draft,omitempty"`
	ReviewStatus string `json:"review_status,omitempty"`
	CIStatus     string `json:"ci_status,omitempty"`
}

LogPRInfo represents PR information in JSON output

type LogSummary

type LogSummary struct {
	TotalBranches int `json:"total_branches"`
	ApprovedCount int `json:"approved_count"`
	InReviewCount int `json:"in_review_count"`
}

LogSummary represents summary statistics in JSON output

type MetadataDiffInfo

type MetadataDiffInfo struct {
	Branch      string   `json:"branch"`
	DiffFields  []string `json:"diff_fields"`
	LocalValue  string   `json:"local_value,omitempty"`
	RemoteValue string   `json:"remote_value,omitempty"`
}

MetadataDiffInfo represents a difference between local and remote metadata

type MetadataPushEngine

type MetadataPushEngine interface {
	BatchSetLastModifiedBy(branchNames []string) error
	IsRemoteSyncEnabled() bool
	SetRemoteSyncEnabled(enabled bool)
	Git() git.Runner
}

MetadataPushEngine defines the engine capabilities needed for pushing metadata.

type ModifyOptions

type ModifyOptions struct {
	// Staging options
	All    bool // Stage all changes before committing (-a)
	Update bool // Stage updates to tracked files only (-u)
	Patch  bool // Pick hunks to stage interactively (-p)

	// Commit options
	CreateCommit bool   // Create a new commit instead of amending (-c)
	Message      string // Commit message (-m)
	Edit         bool   // Open editor to edit commit message (-e)
	NoEdit       bool   // Don't edit commit message (computed from flags)
	ResetAuthor  bool   // Reset author to current user
	Verbose      int    // Show diff in commit message template (-v)

	// Interactive rebase
	InteractiveRebase bool // Start interactive rebase on branch commits
}

ModifyOptions contains options for the modify command

type NullCheckoutHandler

type NullCheckoutHandler struct{}

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

func (*NullCheckoutHandler) SelectBranch

func (h *NullCheckoutHandler) SelectBranch(_ *app.Context, _ CheckoutOptions) (string, error)

SelectBranch returns an error since interactive selection is not available

type PRNumber

type PRNumber int

PRNumber is a type alias for a GitHub pull request number

type PopOptions

type PopOptions struct {
}

PopOptions contains options for the pop command

type RemoteMetadataStateInfo

type RemoteMetadataStateInfo struct {
	RemoteStateAvailable bool                     `json:"remote_state_available"`
	RemoteRefs           map[string]RemoteRefInfo `json:"remote_refs,omitempty"`
	LocalVsRemoteDiffs   []MetadataDiffInfo       `json:"local_vs_remote_diffs,omitempty"`
}

RemoteMetadataStateInfo represents the state of metadata on the remote

type RemoteRefInfo

type RemoteRefInfo struct {
	SHA          string `json:"sha"`
	LastModified string `json:"last_modified,omitempty"`
	ModifiedBy   string `json:"modified_by,omitempty"`
	Scope        string `json:"scope,omitempty"`
}

RemoteRefInfo represents information about a single remote ref

type RenameOptions

type RenameOptions struct {
	NewName string
	Force   bool
}

RenameOptions contains options for the rename command

type RepositoryInfo

type RepositoryInfo struct {
	RemoteURL string `json:"remote_url,omitempty"`
	RepoRoot  string `json:"repo_root,omitempty"`
}

RepositoryInfo represents basic repository information

type RestackOptions

type RestackOptions struct {
	BranchName         string
	Scope              engine.StackRange
	AllStacks          bool
	StackRoots         []string
	ContinueOnConflict bool
	Parallel           bool // Run independent stack groups in parallel worktrees
	Jobs               int  // Number of parallel workers (0 = NumCPU)
}

RestackOptions contains options for the restack command

type RestackPlan

type RestackPlan struct {
	// contains filtered or unexported fields
}

RestackPlan is the precomputed work for a restack operation. Build it via PlanRestack, inspect via HasBranches/HasWork, then pass it to RestackAction.

Sharing the plan between the CLI's "is there work?" gate and the action itself avoids running engine.PlanRestack twice — that's ~3 git operations per branch, ~10ms/branch on a warm filesystem.

func PlanRestack

func PlanRestack(ctx *app.Context, opts RestackOptions) (*RestackPlan, error)

PlanRestack resolves the branch groups for opts and pre-computes the engine restack plan for each group. Pass the result to RestackAction to skip recomputing those plans during execution.

The per-group engine plan is *not* reused in parallel mode — each worktree has its own engine and must compute its own plan against worktree-local state.

func (*RestackPlan) BranchCount

func (p *RestackPlan) BranchCount() int

BranchCount returns the total number of branches across all groups.

func (*RestackPlan) HasBranches

func (p *RestackPlan) HasBranches() bool

HasBranches reports whether any branch was resolved from the requested scope. False means the scope is empty (e.g. on trunk with no children).

func (*RestackPlan) HasWork

func (p *RestackPlan) HasWork() bool

HasWork reports whether any resolved branch needs an actual rebase. Branches that are up-to-date, locked, or frozen do not count.

type RestackProgress

type RestackProgress struct {
	Branch              string               // the branch being processed
	Result              engine.RestackResult // Done, Unneeded, or Conflict
	NewRev              string               // new revision if restacked (empty otherwise)
	RerereResolvedCount int                  // number of rebase continuations handled by git rerere
	Conflict            bool                 // true if this is a conflict
	LockReason          engine.LockReason    // why the branch is locked (empty if not locked)
	Frozen              bool                 // true if the branch is frozen
	IsCurrent           bool                 // true if this is the current branch
	Reparented          bool                 // true if the branch was reparented
	OldParent           string               // the old parent name if reparented
	NewParent           string               // the new parent name if reparented
	StackRoot           string               // independent stack root (set by multi-stack callers; empty for single-stack)
}

RestackProgress describes the outcome of restacking a single branch. It is passed to RestackProgressCallback so callers can report progress without juggling a long positional parameter list.

type RestackProgressCallback

type RestackProgressCallback func(RestackProgress)

RestackProgressCallback is called for each branch during restack with a RestackProgress describing the outcome.

type Restacker

type Restacker interface {
	engine.BranchReader
	engine.SyncManager
}

Restacker is a minimal interface needed for restacking branches

type SingleBranchInfo

type SingleBranchInfo struct {
	Name             string              `json:"name"`
	IsCurrent        bool                `json:"is_current"`
	IsTrunk          bool                `json:"is_trunk"`
	IsLocked         bool                `json:"is_locked"`
	IsFrozen         bool                `json:"is_frozen"`
	NeedsRestack     bool                `json:"needs_restack"`
	Scope            string              `json:"scope"`
	CommitDate       string              `json:"commit_date,omitempty"`
	Parent           string              `json:"parent,omitempty"`
	Children         []string            `json:"children,omitempty"`
	PR               *SingleBranchPRInfo `json:"pr,omitempty"`
	CommitMessages   []string            `json:"commit_messages"`
	DiffStats        SingleBranchStats   `json:"diff_stats"`
	StackTitle       string              `json:"stack_title,omitempty"`
	StackDescription string              `json:"stack_description,omitempty"`
}

SingleBranchInfo represents JSON-serializable info for a single branch (used by info --json)

type SingleBranchPRInfo

type SingleBranchPRInfo struct {
	Number  int    `json:"number"`
	Title   string `json:"title"`
	State   string `json:"state"`
	IsDraft bool   `json:"is_draft"`
	URL     string `json:"url"`
}

SingleBranchPRInfo represents PR information for JSON output

type SingleBranchStats

type SingleBranchStats struct {
	FilesChanged int `json:"files_changed"`
	Additions    int `json:"additions"`
	Deletions    int `json:"deletions"`
}

SingleBranchStats represents diff statistics for a branch

type SnapshotOption

type SnapshotOption func(*engine.SnapshotOptions)

SnapshotOption is a function that modifies SnapshotOptions

func WithArg

func WithArg(arg string) SnapshotOption

WithArg appends a single argument if it's not empty

func WithArgs

func WithArgs(args ...string) SnapshotOption

WithArgs appends multiple arguments

func WithFlag

func WithFlag(condition bool, flag string) SnapshotOption

WithFlag appends a flag if condition is true

func WithFlagValue

func WithFlagValue(flag string, value string) SnapshotOption

WithFlagValue appends a flag with a value if the value is not empty

type SquashOptions

type SquashOptions struct {
	Message string
	NoEdit  bool
}

SquashOptions contains options for the squash command

type StackBranchInfo

type StackBranchInfo struct {
	Name           string    `json:"name"`
	Parent         string    `json:"parent"`
	IsLocked       bool      `json:"is_locked"`
	IsFrozen       bool      `json:"is_frozen"`
	Scope          string    `json:"scope"`
	PRNumber       *int      `json:"pr_number,omitempty"`
	PRURL          string    `json:"pr_url,omitempty"`
	CommitMessages []string  `json:"commit_messages"`
	DiffStats      DiffStats `json:"diff_stats"`
}

StackBranchInfo represents JSON-serializable info for a single branch in a stack

type StackInfoOptions

type StackInfoOptions struct {
	JSON bool
}

StackInfoOptions contains options for the stack info logic

type StackInfoOutput

type StackInfoOutput struct {
	StackTitle       string            `json:"stack_title,omitempty"`
	StackDescription string            `json:"stack_description,omitempty"`
	Branches         []StackBranchInfo `json:"branches"`
}

StackInfoOutput represents JSON-serializable output for the stack info command

type StackStateInfo

type StackStateInfo struct {
	Trunk         string       `json:"trunk"`
	CurrentBranch string       `json:"current_branch"`
	Branches      []BranchInfo `json:"branches"`
}

StackStateInfo represents the complete stack state

Directories

Path Synopsis
Package abort implements the stackit abort command for canceling in-progress operations.
Package abort implements the stackit abort command for canceling in-progress operations.
Package absorb provides functionality for absorbing staged changes into commits downstack.
Package absorb provides functionality for absorbing staged changes into commits downstack.
Package create provides functionality for creating new stacked branches.
Package create provides functionality for creating new stacked branches.
Package delete provides functionality for deleting branches and their metadata.
Package delete provides functionality for deleting branches and their metadata.
Package describe implements the stackit describe command for managing stack descriptions.
Package describe implements the stackit describe command for managing stack descriptions.
Package doctor provides diagnostic functionality for checking stackit environment and repository health.
Package doctor provides diagnostic functionality for checking stackit environment and repository health.
Package flatten provides functionality for flattening stacked branches closer to trunk.
Package flatten provides functionality for flattening stacked branches closer to trunk.
Package fold provides functionality for folding stacked branches.
Package fold provides functionality for folding stacked branches.
Package foreach provides functionality for executing a command on each branch in a stack.
Package foreach provides functionality for executing a command on each branch in a stack.
Package handler provides common handler types and base implementations for action handlers throughout the stackit codebase.
Package handler provides common handler types and base implementations for action handlers throughout the stackit codebase.
Package init provides functionality for initializing Stackit in a Git repository.
Package init provides functionality for initializing Stackit in a Git repository.
Package integrations provides functionality for integrating Stackit with external tools and hooks.
Package integrations provides functionality for integrating Stackit with external tools and hooks.
Package lock provides functionality for locking and unlocking branches in a stack.
Package lock provides functionality for locking and unlocking branches in a stack.
Package merge provides functionality for merging stacked pull requests.
Package merge provides functionality for merging stacked pull requests.
Package move provides functionality for moving branches to different parents in the stack.
Package move provides functionality for moving branches to different parents in the stack.
Package navigation implements the stackit top/bottom commands for navigating stacked branches.
Package navigation implements the stackit top/bottom commands for navigating stacked branches.
Package pluck provides functionality for extracting a single branch from a stack.
Package pluck provides functionality for extracting a single branch from a stack.
Package scope implements the stackit scope command for managing branch scopes.
Package scope implements the stackit scope command for managing branch scopes.
Package split provides functionality for splitting stacked branches.
Package split provides functionality for splitting stacked branches.
Package submit provides functionality for submitting stacked branches as pull requests.
Package submit provides functionality for submitting stacked branches as pull requests.
Package sync provides functionality for synchronizing stacked branches with remote repositories.
Package sync provides functionality for synchronizing stacked branches with remote repositories.
Package track implements the stackit track command for tracking branches in a stack.
Package track implements the stackit track command for tracking branches in a stack.
Package undo provides functionality for undoing stackit operations using snapshots.
Package undo provides functionality for undoing stackit operations using snapshots.
Package untrack implements the stackit untrack command for stopping branch tracking.
Package untrack implements the stackit untrack command for stopping branch tracking.
Package validation provides reusable precondition validators for actions.
Package validation provides reusable precondition validators for actions.
Package worktree provides actions for managing stackit-managed worktrees.
Package worktree provides actions for managing stackit-managed worktrees.

Jump to

Keyboard shortcuts

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