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

delete

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

Documentation

Overview

Package delete provides functionality for deleting branches and their metadata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps added in v0.30.1

type Deps struct {
	Engine Engine
	actions.MutationDeps
}

Deps are the collaborators delete needs. Adapters build them from their own runtime state; the action never sees bootstrap types.

type Engine added in v0.30.1

type Engine interface {
	validation.BranchValidationEngine
	actions.OwnershipEngine
	Trunk() engine.Branch
	AllBranches() engine.Branches
	Graph(ctx context.Context, strategy engine.SortStrategy) *engine.StackGraph
	FindNearestNonExcludedAncestor(startParent string, isExcluded func(name string) bool) string
	GetDeletionStatuses(ctx context.Context, branchNames []string) (engine.DeletionStatuses, error)
	DeleteBranches(ctx context.Context, branches engine.Branches) ([]string, error)
	ApplyParentUpdatesAfterRemovals(ctx context.Context, updates []engine.BranchParentUpdate, removed []string) error
	DeleteRemoteMetadataForBranches(ctx context.Context, branchNames []string) error
	GetWorktreeForStack(ctx context.Context, stackRoot string) (*engine.WorktreeInfo, error)
	RemoveWorktree(ctx context.Context, path engine.WorktreePath) error
	UnregisterWorktree(ctx context.Context, stackRoot string) error
}

Engine lists exactly the engine methods delete calls: the branch validators, deletion and reparenting, remote metadata cleanup, and the worktree registry for stacks that disappear entirely.

type Handler

type Handler interface {
	// Start is called at the beginning of delete
	Start(branchCount int)

	// OnBranch is called for each branch being deleted
	OnBranch(name string, status Status, prNumber *git.PRNumber)

	// OnRestack is called when restacking children
	OnRestack(childCount int)

	// Complete is called when delete finishes
	Complete(deleted, skipped int)

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

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

	// PromptConfirm prompts user for confirmation before deleting
	PromptConfirm(branch string, reason string) (bool, error)
}

Handler receives events from delete action

type NullHandler

type NullHandler struct {
	handler.NullBase
}

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(int, int)

Complete implements Handler.

func (*NullHandler) OnBranch

func (h *NullHandler) OnBranch(string, Status, *git.PRNumber)

OnBranch implements Handler.

func (*NullHandler) OnRestack

func (h *NullHandler) OnRestack(int)

OnRestack implements Handler.

func (*NullHandler) PromptConfirm

func (h *NullHandler) PromptConfirm(string, string) (bool, error)

PromptConfirm implements Handler.

func (*NullHandler) Start

func (h *NullHandler) Start(int)

Start implements Handler.

type Options

type Options struct {
	BranchName string
	Downstack  bool
	Force      bool
	Upstack    bool
}

Options contains options for deleting branches

type Result

type Result struct {
	MainRepoDirForSwitch string
}

Result contains the result of the delete action.

func Action

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

Action deletes a branch and its metadata.

type Status

type Status string

Status represents the status of a branch deletion

const (
	StatusDeleted   Status = "deleted"
	StatusSkipped   Status = "skipped"
	StatusRestacked Status = "restacked"
)

Delete status constants

Jump to

Keyboard shortcuts

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