create

package
v0.17.14 Latest Latest
Warning

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

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

Documentation

Overview

Package create provides functionality for creating new stacked branches.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	// Start is called at the beginning of create
	Start(parentBranch string)

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

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

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

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

	// PromptStageChanges prompts user to stage unstaged changes
	PromptStageChanges() (bool, error)

	// PromptScope prompts user for a scope value when pattern contains {scope}
	// The patternHint shows the current branch pattern to the user
	PromptScope(patternHint string) (string, error)
}

Handler receives events from create action

type NullHandler

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

NullHandler is a no-op handler for when nil is passed

func (*NullHandler) Complete

func (h *NullHandler) Complete(_ Result)

Complete implements Handler.

func (*NullHandler) PromptScope

func (h *NullHandler) PromptScope(_ string) (string, error)

PromptScope implements Handler.

func (*NullHandler) PromptStageChanges

func (h *NullHandler) PromptStageChanges() (bool, error)

PromptStageChanges implements Handler.

func (*NullHandler) Start

func (h *NullHandler) Start(_ string)

Start implements Handler.

type Options

type Options struct {
	BranchName    string
	Message       string
	Scope         string
	All           bool
	Insert        bool
	Patch         bool
	Update        bool
	Verbose       int
	BranchPattern config.BranchPattern
	// SelectedChildren is used to specify which children to move during insert
	// in non-interactive mode (mostly for tests)
	SelectedChildren []string
	// Worktree creates a dedicated worktree for this stack (only valid from trunk)
	Worktree bool
}

Options contains options for the create command

type Result

type Result struct {
	BranchName   string
	ParentBranch string
	HasCommit    bool
	WorktreePath string
}

Result contains the result of the create action.

func Action

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

Action creates a new branch stacked on top of the current branch.

type Step

type Step string

Step represents a step in the create process

const (
	StepStaging      Step = "staging"
	StepMessage      Step = "message"
	StepBranchCreate Step = "branch_create"
	StepCommit       Step = "commit"
	StepTracking     Step = "tracking"
	StepWorktree     Step = "worktree"
	StepScope        Step = "scope"
	StepInsert       Step = "insert"
)

Create step constants

Jump to

Keyboard shortcuts

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