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

pluck

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package pluck provides functionality for extracting a single branch from a stack.

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 pluck operation. Pluck extracts a single branch from its current position and moves it to a new parent. Unlike move, pluck does NOT bring descendants along - they are reparented to the grandparent (the plucked branch's former parent).

func InvalidOntoTargets added in v0.29.0

func InvalidOntoTargets(eng engine.StackView, source string) map[string]bool

InvalidOntoTargets returns the branches source cannot be plucked onto: source itself and all of its descendants.

Types

type Handler

type Handler interface {
	// Start is called at the beginning of pluck
	Start(move basehandler.Reparent)

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

	// OnChildReparented is called when a child is reparented to the grandparent
	OnChildReparented(move basehandler.Reparent)

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

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

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

	// PromptConfirmPluck displays a preview of the pluck and asks for confirmation.
	// Returns true to proceed with the pluck, false to cancel.
	// In non-interactive mode, returns true (auto-confirm).
	PromptConfirmPluck(preview Preview) (bool, error)
}

Handler receives events from pluck action

type NullHandler

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

NullHandler is a no-op handler for when nil is passed. It embeds basehandler.NullBase for Cleanup() and IsInteractive(), and basehandler.NullProgress[Step] for OnStep().

func (*NullHandler) Complete

func (h *NullHandler) Complete(Result)

Complete implements Handler.

func (*NullHandler) OnChildReparented

func (h *NullHandler) OnChildReparented(basehandler.Reparent)

OnChildReparented implements Handler.

func (*NullHandler) PromptConfirmPluck

func (h *NullHandler) PromptConfirmPluck(Preview) (bool, error)

PromptConfirmPluck implements Handler. Returns true (auto-confirm) for null handler.

func (*NullHandler) Start

func (h *NullHandler) Start(basehandler.Reparent)

Start implements Handler.

type Options

type Options struct {
	Source      string // Branch to pluck (defaults to current branch)
	Onto        string // Branch to pluck onto
	SkipConfirm bool   // Skip confirmation prompt (--yes flag)
}

Options contains options for the pluck command

type Preview

type Preview struct {
	SourceBranch   string   // Branch being plucked
	OldParent      string   // Current parent of source
	NewParent      string   // Target parent for source
	Children       []string // Direct children that will be reparented
	ChildNewParent string   // Where children will be reparented (grandparent)
	Commits        []string // Commit subjects on the source branch
}

Preview contains information about the planned pluck for confirmation

type Result

type Result struct {
	SourceBranch       string   // Branch that was plucked
	OldParent          string   // Previous parent of source
	NewParent          string   // New parent of source
	ReparentedChildren []string // Children that were reparented to grandparent
}

Result contains the result of the pluck action

type Step

type Step string

Step represents a step in the pluck process

const (
	StepValidating        Step = "validating"
	StepReparentingChild  Step = "reparenting-child"
	StepMovingSource      Step = "moving-source"
	StepRestackingOrphans Step = "restacking-orphans"
)

Pluck step constants

Jump to

Keyboard shortcuts

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