Documentation
¶
Overview ¶
Package move provides functionality for moving branches to different parents in the stack.
Index ¶
- func Action(ctx *app.Context, opts Options, h Handler) error
- func BuildRebaseSpecs(eng engine.Engine, out output.Output, source, onto string, ...) []engine.RebaseSpec
- func SelectOntoInteractive(ctx *app.Context, sourceBranch string) (string, []engine.RebaseSpec, error)
- type Handler
- type NullHandler
- func (h *NullHandler) Complete(Result)
- func (h *NullHandler) OnRename(string, string)
- func (h *NullHandler) PromptConfirmMove(Preview) (bool, error)
- func (h *NullHandler) PromptRename(string, string, string) (bool, error)
- func (h *NullHandler) PromptSelectOnto(*app.Context, string) (string, []engine.RebaseSpec, error)
- func (h *NullHandler) Start(string, string, string)
- type Options
- type Preview
- type Result
- type Selection
- type Step
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildRebaseSpecs ¶
func BuildRebaseSpecs(eng engine.Engine, out output.Output, source, onto string, oldParent *engine.Branch, oldParentRev string, descendants []engine.Branch) []engine.RebaseSpec
BuildRebaseSpecs builds the rebase specifications for validating/executing the move. Exported so it can be used by the selection validation callback.
func SelectOntoInteractive ¶
func SelectOntoInteractive(ctx *app.Context, sourceBranch string) (string, []engine.RebaseSpec, error)
SelectOntoInteractive shows an interactive branch selector for choosing the "onto" branch and returns precomputed rebase specs for the final selection. This uses a compact inline bubbletea model that combines selection and confirmation.
Types ¶
type Handler ¶
type Handler interface {
// Start is called at the beginning of move
Start(sourceBranch, oldParent, newParent string)
// OnStep is called for each step in the move process
OnStep(step Step, status handler.StepStatus, message string)
// OnRename is called when a branch is renamed due to scope change
OnRename(oldName, newName string)
// Complete is called when move finishes
Complete(result Result)
// Cleanup restores terminal state (may be no-op)
Cleanup()
// IsInteractive returns true if the handler supports interactive prompts
IsInteractive() bool
// PromptRename prompts user to confirm branch rename due to scope change
PromptRename(oldName, oldScope, newScope string) (bool, error)
// PromptConfirmMove displays a preview of the move and asks for confirmation.
// Returns true to proceed with the move, false to cancel.
// In non-interactive mode, returns true (auto-confirm).
PromptConfirmMove(preview Preview) (bool, error)
// PromptSelectOnto prompts user to select a new parent when --onto is not provided.
// Returns the selected branch and any precomputed rebase specs.
PromptSelectOnto(ctx *app.Context, sourceBranch string) (string, []engine.RebaseSpec, error)
}
Handler receives events from move 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) OnRename ¶
func (h *NullHandler) OnRename(string, string)
OnRename implements Handler.
func (*NullHandler) PromptConfirmMove ¶
func (h *NullHandler) PromptConfirmMove(Preview) (bool, error)
PromptConfirmMove implements Handler. Returns true (auto-confirm) for null handler.
func (*NullHandler) PromptRename ¶
PromptRename implements Handler.
func (*NullHandler) PromptSelectOnto ¶
func (h *NullHandler) PromptSelectOnto(*app.Context, string) (string, []engine.RebaseSpec, error)
PromptSelectOnto implements Handler. Returns error for null handler.
type Options ¶
type Options struct {
Source string // Branch to move (defaults to current branch)
Onto string // Branch to move onto
SkipConfirm bool // Skip confirmation prompt (--yes flag)
DryRun bool // If true, only shows what would happen without making changes
AutoRename bool // Auto-rename branch when scope changes (non-interactive mode)
// RebaseSpecs optionally provides precomputed specs (e.g. from interactive selection).
RebaseSpecs []engine.RebaseSpec
}
Options contains options for the move command
type Preview ¶
type Preview struct {
SourceBranch string // Branch being moved
OldParent string // Current parent branch
NewParent string // Target parent branch
Commits []string // Commit subjects that will be moved
Descendants []string // Descendant branches that will be restacked
HasConflicts bool // Whether the move will cause conflicts
ConflictBranch string // Which branch would have conflicts (if any)
ConflictError string // Error message describing the conflict
ConflictingFiles []string // Files that have conflicts (if any)
}
Preview contains information about the planned move for confirmation
type Result ¶
type Result struct {
SourceBranch string
OldParent string
NewParent string
Renamed bool
NewName string
}
Result contains the result of the move action
type Selection ¶
type Selection struct {
// contains filtered or unexported fields
}
Selection contains precomputed data for validating potential move targets.
func PrepareSelection ¶
PrepareSelection builds the data needed for interactive onto validation.
func (*Selection) Descendants ¶
Descendants returns the descendant branches (including the source).
func (*Selection) OldParentRev ¶
OldParentRev returns the captured old parent revision.
func (*Selection) ValidateOnto ¶
func (s *Selection) ValidateOnto(ctx context.Context, onto string) (*engine.RebaseValidation, []string, []engine.RebaseSpec, error)
ValidateOnto validates a potential move target and returns validation, commits, and rebase specs.