Documentation
¶
Overview ¶
Package handlers provides shared handler interfaces for CLI output.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONRestackHandler ¶
type JSONRestackHandler struct {
Result *RestackJSONResult
// contains filtered or unexported fields
}
JSONRestackHandler collects restack results for JSON output. All methods are mutex-protected so concurrent callers (parallel restack) are safe.
func NewJSONRestackHandler ¶
func NewJSONRestackHandler() *JSONRestackHandler
NewJSONRestackHandler creates a new JSON handler
func (*JSONRestackHandler) OnRestackBranch ¶
func (h *JSONRestackHandler) OnRestackBranch(event RestackBranchEvent)
OnRestackBranch implements RestackHandler.
func (*JSONRestackHandler) OnRestackComplete ¶
func (h *JSONRestackHandler) OnRestackComplete(summary RestackSummary)
OnRestackComplete implements RestackHandler.
func (*JSONRestackHandler) OnRestackStart ¶
func (h *JSONRestackHandler) OnRestackStart(branchCount int)
OnRestackStart implements RestackHandler.
func (*JSONRestackHandler) SetError ¶
func (h *JSONRestackHandler) SetError(err error)
SetError sets the error status and message on the result. Call this when the restack action returns an error.
type NullRestackHandler ¶
type NullRestackHandler struct{}
NullRestackHandler is a no-op handler for testing or when output is not needed
func (*NullRestackHandler) OnRestackBranch ¶
func (h *NullRestackHandler) OnRestackBranch(RestackBranchEvent)
OnRestackBranch implements RestackHandler.
func (*NullRestackHandler) OnRestackComplete ¶
func (h *NullRestackHandler) OnRestackComplete(RestackSummary)
OnRestackComplete implements RestackHandler.
func (*NullRestackHandler) OnRestackStart ¶
func (h *NullRestackHandler) OnRestackStart(_ int)
OnRestackStart implements RestackHandler.
type RestackBranchEvent ¶ added in v0.25.0
type RestackBranchEvent struct {
Branch string
Result RestackResult
NewRevision string
PRNumber *int
LockReason engine.LockReason
Frozen bool
HeldBy string // why a worktree held this branch back (empty if it was not held)
IsCurrent bool
Parent string
Reparented bool
OldParent string
NewParent string
RerereResolvedCount int
StackRoot string
}
RestackBranchEvent describes the outcome of restacking one branch. Keeping these facts together makes the shared presentation contract safe to extend without relying on positional arguments.
type RestackBranchInfo ¶
type RestackBranchInfo struct {
Name string `json:"name"`
Parent string `json:"parent"`
StackRoot string `json:"stack_root,omitempty"` // Independent stack root this branch belongs to
NewRev string `json:"new_rev,omitempty"`
PRNumber *int `json:"pr_number,omitempty"`
RerereResolvedCount int `json:"rerere_resolved_count,omitempty"`
}
RestackBranchInfo represents info about a restacked branch
type RestackConflictInfo ¶
type RestackConflictInfo struct {
Branch string `json:"branch"`
Parent string `json:"parent"`
StackRoot string `json:"stack_root,omitempty"` // Independent stack root this branch belongs to
}
RestackConflictInfo represents a conflict during restack
type RestackHandler ¶
type RestackHandler interface {
// OnRestackStart is called at the beginning of restack with branch count
OnRestackStart(branchCount int)
// OnRestackBranch is called for each branch during restack.
OnRestackBranch(event RestackBranchEvent)
// OnRestackComplete is called when restack finishes. blocked lists
// branches left untouched because their stack contained a conflict.
OnRestackComplete(summary RestackSummary)
}
RestackHandler abstracts TTY vs non-TTY output for restack operations This interface is shared between sync, get, and restack commands
type RestackHeldInfo ¶ added in v0.25.0
RestackHeldInfo represents a branch a worktree held back during restack. Held branches are skipped rather than restacked, so scripts must not read an empty conflict list as "the whole stack moved".
type RestackJSONResult ¶
type RestackJSONResult struct {
Status RestackJSONStatus `json:"status"`
Error string `json:"error,omitempty"`
Restacked []RestackBranchInfo `json:"restacked,omitempty"`
Skipped []string `json:"skipped,omitempty"`
Conflicts []RestackConflictInfo `json:"conflicts,omitempty"`
Held []RestackHeldInfo `json:"held,omitempty"` // Branches a worktree held back; also present in Skipped
Blocked []string `json:"blocked,omitempty"` // Branches left untouched because their stack contained a conflict
StackRoots []string `json:"stack_roots,omitempty"` // Deduped independent stack roots that were processed
TotalCount int `json:"total_count"`
RestackCount int `json:"restack_count"`
ConflictCount int `json:"conflict_count"`
BlockedCount int `json:"blocked_count,omitempty"`
}
RestackJSONResult represents the JSON output for restack operations
type RestackJSONStatus ¶
type RestackJSONStatus string
RestackJSONStatus represents the aggregate outcome of a JSON restack operation.
const ( RestackJSONStatusSuccess RestackJSONStatus = "success" RestackJSONStatusConflict RestackJSONStatus = "conflict" RestackJSONStatusError RestackJSONStatus = "error" )
type RestackResult ¶
type RestackResult string
RestackResult represents the outcome of a restack operation for a single branch
const ( // RestackDone indicates the branch was successfully restacked RestackDone RestackResult = "done" // RestackUnneeded indicates the branch didn't need restacking RestackUnneeded RestackResult = "unneeded" // RestackConflict indicates the branch had a conflict RestackConflict RestackResult = "conflict" // RestackBlocked indicates the branch was left untouched because another // branch in its stack conflicted RestackBlocked RestackResult = "blocked" )