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

fold

package
v0.27.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package fold provides functionality for folding stacked branches.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Action

func Action(ctx *app.Context, opts Options, handler Handler) error

Action performs the fold operation

Types

type Handler

type Handler interface {
	// Start is called at the beginning of fold
	Start(currentBranch, parentBranch string, dryRun bool)

	// OnStep is called for each step in the fold process
	OnStep(step Step, status handler.StepStatus, message string)

	// Complete is called when fold finishes
	Complete(result Result)

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

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

Handler receives events from fold action

type NullHandler

type NullHandler struct {
	handler.NullBase
	handler.NullProgress[Step]
}

NullHandler is a no-op handler for when nil is passed. It embeds handler.NullBase for Cleanup() and IsInteractive().

func (*NullHandler) Complete

func (h *NullHandler) Complete(Result)

Complete implements Handler.

func (*NullHandler) Start

func (h *NullHandler) Start(string, string, bool)

Start implements Handler.

type Options

type Options struct {
	Keep       bool // If true, keeps the name of the current branch instead of using the name of its parent
	AllowTrunk bool // If true, allows folding into the trunk branch
	DryRun     bool // If true, only shows what would happen
}

Options contains options for the fold command

type Result

type Result struct {
	FoldedBranch  string
	IntoBranch    string
	ChildrenCount int
}

Result contains the result of the fold action

type Step

type Step string

Step represents a step in the fold process

const (
	StepValidating Step = "validating"
	StepFolding    Step = "folding"
	StepRestacking Step = "restacking"
	StepCleanup    Step = "cleanup"
)

Fold step constants

Jump to

Keyboard shortcuts

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