Documentation
¶
Index ¶
- Constants
- func ApplyPlan(cfg *config.Config, gitDir string, s *stack.Stack, sf *stack.StackFile, ...) (*modifyview.ApplyResult, *modifyview.ConflictInfo, error)
- func CheckNoMergeQueuePRs(cfg *config.Config, s *stack.Stack) error
- func CheckStackLinearity(cfg *config.Config, s *stack.Stack) error
- func CheckStateGuard(gitDir string) error
- func ClearState(gitDir string)
- func ContinueApply(cfg *config.Config, gitDir string, updateBaseSHAs func(*stack.Stack)) error
- func SaveState(gitDir string, state *StateFile) error
- func StateExists(gitDir string) bool
- func StatePath(gitDir string) string
- func Unwind(cfg *config.Config, gitDir string, snapshot Snapshot, stackIndex int, ...) error
- func UnwindFromStateFile(cfg *config.Config, gitDir string) error
- type Action
- type BranchSnapshot
- type Snapshot
- type StateFile
Constants ¶
const ( PhaseApplying = "applying" PhaseConflict = "conflict" PhasePendingSubmit = "pending_submit" )
Variables ¶
This section is empty.
Functions ¶
func ApplyPlan ¶
func ApplyPlan( cfg *config.Config, gitDir string, s *stack.Stack, sf *stack.StackFile, nodes []modifyview.ModifyBranchNode, currentBranch string, updateBaseSHAs func(*stack.Stack), ) (*modifyview.ApplyResult, *modifyview.ConflictInfo, error)
ApplyPlan executes the staged modifications on the stack. updateBaseSHAs is called after rebasing to refresh branch SHAs in the stack metadata. It returns an ApplyResult on success or a ConflictInfo if a rebase conflict occurs.
func CheckNoMergeQueuePRs ¶
CheckNoMergeQueuePRs checks that no unmerged PR in the stack is currently queued.
func CheckStackLinearity ¶
CheckStackLinearity verifies that the stack has unambiguous commit-to-branch mapping. For each adjacent pair (parent, child), checks: 1. parent tip is an ancestor of child tip 2. no merge commits exist in the range parent..child
func CheckStateGuard ¶
CheckStateGuard checks if a modify state file exists with phase "applying" and returns an error if so. This is used as a guard at the top of commands that should not run while a modify is in progress.
func ContinueApply ¶
ContinueApply resumes a modify operation after the user resolves a rebase conflict. It finishes the in-progress git rebase, then continues the cascading rebase for remaining branches stored in the state file.
func StateExists ¶
StateExists returns true if a modify state file exists.
Types ¶
type Action ¶
type Action struct {
Type string `json:"type"` // "drop", "fold_down", "fold_up", "move", "rename"
Branch string `json:"branch"`
NewPosition int `json:"new_position,omitempty"` // for "move"
NewName string `json:"new_name,omitempty"` // for "rename"
}
Action represents a single staged action from the TUI.
func BuildPlan ¶
func BuildPlan(nodes []modifyview.ModifyBranchNode) []Action
BuildPlan converts the TUI's staged actions into a list of Actions suitable for storage in the state file.
type BranchSnapshot ¶
type BranchSnapshot struct {
Name string `json:"name"`
TipSHA string `json:"tip_sha"`
Position int `json:"position"`
}
BranchSnapshot stores the state of a single branch before modification.
type Snapshot ¶
type Snapshot struct {
Branches []BranchSnapshot `json:"branches"`
StackMetadata json.RawMessage `json:"stack_metadata"`
}
Snapshot captures the pre-modify state for unwind/recovery.
type StateFile ¶
type StateFile struct {
SchemaVersion int `json:"schema_version"`
StackName string `json:"stack_name"`
StackIndex int `json:"stack_index"` // index in StackFile.Stacks at modify start
StartedAt time.Time `json:"started_at"`
Phase string `json:"phase"` // "applying", "conflict", or "pending_submit"
PriorRemoteStackID string `json:"prior_remote_stack_id,omitempty"`
Snapshot Snapshot `json:"snapshot"`
Plan []Action `json:"plan"`
// Conflict state — populated when phase is "conflict"
ConflictBranch string `json:"conflict_branch,omitempty"`
ConflictType string `json:"conflict_type,omitempty"` // "rebase" or "cherry_pick"
RemainingBranches []string `json:"remaining_branches,omitempty"`
OriginalBranch string `json:"original_branch,omitempty"`
OriginalRefs map[string]string `json:"original_refs,omitempty"`
// Cherry-pick conflict context — which fold was in progress
FoldBranch string `json:"fold_branch,omitempty"` // branch being folded
FoldTarget string `json:"fold_target,omitempty"` // branch receiving the cherry-pick
}
StateFile holds the state of an in-progress or pending-submit modify operation. It is stored at .git/gh-stack-modify-state.