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 CheckWorktrees(s *stack.Stack) (*worktree.Context, error)
- func ClearState(gitDir string) error
- func ConflictOps(state *StateFile) (git.Ops, string, error)
- func ContinueApply(cfg *config.Config, gitDir string, updateBaseSHAs func(*stack.Stack)) error
- func MatchesStack(state *StateFile, target *stack.Stack) bool
- 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 CheckWorktrees ¶ added in v0.2.0
CheckWorktrees resolves the initiating worktree. Action-specific owner preflight runs after the TUI has produced its plan.
func ConflictOps ¶ added in v0.2.0
ConflictOps resolves the native operation's worktree, which can differ from both the invoking worktree and the source branch of a fold.
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 MatchesStack ¶ added in v0.2.0
MatchesStack never uses the catalog position as an identity. Older records can be identified by their remote ID or the original snapshot.
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"
Target string `json:"target,omitempty"` // fold receiver, insertion parent, or normalization drop
}
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"` // legacy hint, never an identity
StartedAt time.Time `json:"started_at"`
Phase string `json:"phase"`
PriorRemoteStackID string `json:"prior_remote_stack_id,omitempty"`
Snapshot Snapshot `json:"snapshot"`
Plan []Action `json:"plan"`
Worktrees *worktree.Context `json:"worktrees,omitempty"`
StackBranches []string `json:"stack_branches"`
PreviousStackBranches []string `json:"previous_stack_branches"`
RenamedBranches map[string]string `json:"renamed_branches,omitempty"`
CreatedBranches map[string]string `json:"created_branches,omitempty"`
PendingAction *Action `json:"pending_action,omitempty"`
Execution []Action `json:"execution,omitempty"`
NextAction int `json:"next_action,omitempty"`
DesiredOrder []string `json:"desired_order"`
TrunkSHA string `json:"trunk_sha,omitempty"`
PendingHead string `json:"pending_head,omitempty"`
// 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
// AffectsPRs records whether any action so far has affected a branch with
// a PR. Persisted across conflict boundaries so ContinueApply can combine
// it with checks on remaining branches.
AffectsPRs bool `json:"affects_prs,omitempty"`
}
StateFile holds the state of an in-progress or pending-submit modify operation. It is stored at <common-dir>/gh-stack-modify-state.
func LoadState ¶
LoadState reads the modify state file from the git directory. Returns nil, nil if the file does not exist.