Documentation
¶
Index ¶
- type AfterRebaseCallback
- type BeforeRebaseCallback
- type CleanupResult
- type Manager
- func (m *Manager) AddBranchToStack(name, parentBranch, worktreeDir string) (*config.Branch, error)
- func (m *Manager) AddWorktreeToStack(branchName, worktreePath, parentName string) (*config.Branch, error)
- func (m *Manager) CleanupMergedBranches(branches []MergedBranchInfo, currentDir string) []CleanupResult
- func (m *Manager) CreateBranch(name, parentBranch, worktreeDir string) (*config.Branch, error)
- func (m *Manager) CreateWorktreeOnly(name, parentBranch, worktreeDir string) error
- func (m *Manager) DeleteBranch(branchName string, force bool) error
- func (m *Manager) DetectMergedBranches(gh *github.Client) ([]MergedBranchInfo, error)
- func (m *Manager) DetectMergedBranchesAllStacks(gh *github.Client) ([]MergedBranchInfo, error)
- func (m *Manager) DetectMissingWorktrees() []MissingWorktreeInfo
- func (m *Manager) DetectOrphanedBranches() []string
- func (m *Manager) DetectSyncNeeded(gh *github.Client) ([]SyncInfo, error)
- func (m *Manager) DetectSyncNeededAllStacks(gh *github.Client) ([]SyncInfo, error)
- func (m *Manager) DetectSyncNeededForBranch(branchName string, gh *github.Client) *SyncInfo
- func (m *Manager) GetAllBranchesInAllStacks() []*config.Branch
- func (m *Manager) GetBranch(name string) *config.Branch
- func (m *Manager) GetChildren(branchName string) []*config.Branch
- func (m *Manager) GetCurrentStack() (*config.Stack, *config.Branch, error)
- func (m *Manager) GetRepoDir() string
- func (m *Manager) GetUnregisteredWorktrees() ([]git.Worktree, error)
- func (m *Manager) HandleMissingWorktrees(branches []MissingWorktreeInfo) error
- func (m *Manager) IsMainBranch(name string) bool
- func (m *Manager) ListStacks() []*config.Stack
- func (m *Manager) MarkBranchMerged(branchName string) error
- func (m *Manager) RebaseChildren() ([]RebaseResult, error)
- func (m *Manager) RebaseOnParent() error
- func (m *Manager) RegisterExistingBranch(branchName, worktreePath, baseBranch string) (*config.Branch, error)
- func (m *Manager) RegisterRemoteBranch(branchName, baseBranch string, prNumber int, prURL string) (*config.Branch, error)
- func (m *Manager) RemoveOrphanedBranches(branchNames []string) error
- func (m *Manager) ReparentBranch(branchName, newParentName string, doRebase bool) (*config.Branch, error)
- func (m *Manager) SyncBranch(branchName string, gh *github.Client) (*RebaseResult, error)
- func (m *Manager) SyncStack(gh *github.Client, callbacks *SyncCallbacks) ([]RebaseResult, error)
- func (m *Manager) SyncStackAll(gh *github.Client, callbacks *SyncCallbacks) ([]RebaseResult, error)
- func (m *Manager) UntrackBranch(branchName string) error
- type MergedBranchInfo
- type MissingWorktreeInfo
- type RebaseResult
- type ReparentInfo
- type SyncCallbacks
- type SyncInfo
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AfterRebaseCallback ¶
type AfterRebaseCallback func(result RebaseResult, g *git.Git) bool
AfterRebaseCallback is called after each successful rebase It receives the result and the git instance for the worktree Returns true if sync should continue, false to stop
type BeforeRebaseCallback ¶
BeforeRebaseCallback is called before each rebase to ask for confirmation It receives the sync info for the branch about to be synced Returns true to proceed with rebase, false to skip this branch
type CleanupResult ¶
type CleanupResult struct {
Branch string
Success bool
Error string
WorktreeWasDeleted bool // True if worktree was already deleted before cleanup
}
CleanupResult contains information about a branch cleanup operation
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles stack operations
func NewManager ¶
NewManager creates a new stack manager
func (*Manager) AddBranchToStack ¶
AddBranchToStack adds an existing branch to a stack (worktree should already exist) This is used when the worktree was created externally (e.g., from a remote branch)
func (*Manager) AddWorktreeToStack ¶
func (m *Manager) AddWorktreeToStack(branchName, worktreePath, parentName string) (*config.Branch, error)
AddWorktreeToStack adds an unregistered worktree to a stack with the specified parent
func (*Manager) CleanupMergedBranches ¶
func (m *Manager) CleanupMergedBranches(branches []MergedBranchInfo, currentDir string) []CleanupResult
CleanupMergedBranches marks branches as merged - deletes worktrees and git branches but keeps metadata in config This allows merged PRs to still show up in ezs ls/status with strikethrough styling Returns detailed results for each branch cleanup operation
func (*Manager) CreateBranch ¶
CreateBranch creates a new branch in the stack
func (*Manager) CreateWorktreeOnly ¶
CreateWorktreeOnly creates a worktree without adding it to a stack This is used when the user wants to create a standalone worktree from main/master
func (*Manager) DeleteBranch ¶
DeleteBranch removes a branch from the stack and deletes its worktree Returns an error if the branch has child branches
func (*Manager) DetectMergedBranches ¶
func (m *Manager) DetectMergedBranches(gh *github.Client) ([]MergedBranchInfo, error)
DetectMergedBranches finds branches in the CURRENT stack whose PRs have been merged to main These are candidates for cleanup (deleting local branch and worktree)
func (*Manager) DetectMergedBranchesAllStacks ¶
func (m *Manager) DetectMergedBranchesAllStacks(gh *github.Client) ([]MergedBranchInfo, error)
DetectMergedBranchesAllStacks finds branches across ALL stacks whose PRs have been merged to main
func (*Manager) DetectMissingWorktrees ¶
func (m *Manager) DetectMissingWorktrees() []MissingWorktreeInfo
DetectMissingWorktrees finds branches whose worktree directories no longer exist on disk This can happen when a user manually removes a worktree with `rm -rf`
func (*Manager) DetectOrphanedBranches ¶
DetectOrphanedBranches finds branches in config that no longer exist in git
func (*Manager) DetectSyncNeeded ¶
DetectSyncNeeded checks for branches that need syncing in the CURRENT stack only: - Branches whose parents have been merged to main - Branches whose parent is main but are behind origin/main
func (*Manager) DetectSyncNeededAllStacks ¶
DetectSyncNeededAllStacks checks for branches that need syncing across ALL stacks: - Branches whose parents have been merged to main - Branches whose parent is main but are behind origin/main
func (*Manager) DetectSyncNeededForBranch ¶
DetectSyncNeededForBranch checks if a specific branch needs syncing Returns SyncInfo if the branch needs syncing, nil otherwise
func (*Manager) GetAllBranchesInAllStacks ¶
GetAllBranchesInAllStacks returns all branches across all stacks
func (*Manager) GetChildren ¶
GetChildren returns all child branches of a given branch
func (*Manager) GetCurrentStack ¶
GetCurrentStack returns the stack for the current branch
func (*Manager) GetRepoDir ¶
GetRepoDir returns the main repository directory
func (*Manager) GetUnregisteredWorktrees ¶
GetUnregisteredWorktrees returns worktrees that exist but are not registered in any stack
func (*Manager) HandleMissingWorktrees ¶
func (m *Manager) HandleMissingWorktrees(branches []MissingWorktreeInfo) error
HandleMissingWorktrees cleans up branches whose worktrees were manually removed It removes the branches from the stack config (git worktree prune should be called first)
func (*Manager) IsMainBranch ¶
IsMainBranch checks if a branch is the main/master branch
func (*Manager) ListStacks ¶
ListStacks returns all stacks
func (*Manager) MarkBranchMerged ¶
MarkBranchMerged marks a branch as merged - deletes worktree and git branch but keeps metadata in config This allows merged branches to still show up in ezs ls/status with strikethrough The tree structure is NOT modified - children stay under the merged parent for display order. The effective git parent for children is computed at runtime by skipping merged ancestors.
func (*Manager) RebaseChildren ¶
func (m *Manager) RebaseChildren() ([]RebaseResult, error)
RebaseChildren rebases all child branches after updating the current branch Returns results for each child branch processed
func (*Manager) RebaseOnParent ¶
RebaseOnParent rebases the current branch onto its updated parent
func (*Manager) RegisterExistingBranch ¶
func (m *Manager) RegisterExistingBranch(branchName, worktreePath, baseBranch string) (*config.Branch, error)
RegisterExistingBranch registers an existing branch/worktree as the root of a new stack
func (*Manager) RegisterRemoteBranch ¶
func (m *Manager) RegisterRemoteBranch(branchName, baseBranch string, prNumber int, prURL string) (*config.Branch, error)
RegisterRemoteBranch registers a remote branch (someone else's PR) as the root of a new stack Remote branches don't have local worktrees - only their child branches do
func (*Manager) RemoveOrphanedBranches ¶
RemoveOrphanedBranches removes branches from config that no longer exist in git
func (*Manager) ReparentBranch ¶
func (m *Manager) ReparentBranch(branchName, newParentName string, doRebase bool) (*config.Branch, error)
ReparentBranch changes the parent of a branch to a new parent This handles several cases: 1. Branch is already in a stack - just update parent pointer 2. Branch is standalone (not in any stack) - add it to the new parent's stack 3. New parent is in a different stack - merge stacks or move branch If doRebase is true, performs git rebase --onto to move commits Returns the updated branch and any error
func (*Manager) SyncBranch ¶
SyncBranch syncs a specific branch, handling all cases: - Branch is behind origin/main (parent is main) - Parent branch was merged (rebase --onto main) - Branch is behind its parent (rebase onto parent)
func (*Manager) SyncStack ¶
func (m *Manager) SyncStack(gh *github.Client, callbacks *SyncCallbacks) ([]RebaseResult, error)
SyncStack syncs branches in the CURRENT stack only that need syncing This handles three cases: - Branches whose parent is main but are behind origin/main (simple rebase) - Branches whose parent was merged (rebase onto main using --onto) - Branches whose parent is not merged but has new commits (rebase onto parent) Callbacks can be used to ask for confirmation before each rebase and push after
func (*Manager) SyncStackAll ¶
func (m *Manager) SyncStackAll(gh *github.Client, callbacks *SyncCallbacks) ([]RebaseResult, error)
SyncStackAll syncs branches in ALL stacks that need syncing
func (*Manager) UntrackBranch ¶
UntrackBranch removes a branch from ezstack tracking without deleting the git branch or worktree Children of the untracked branch are reparented to the untracked branch's parent
type MergedBranchInfo ¶
MergedBranchInfo contains information about a branch whose PR has been merged
type MissingWorktreeInfo ¶
MissingWorktreeInfo contains info about a branch whose worktree was removed
type RebaseResult ¶
type RebaseResult struct {
Branch string
Success bool
HasConflict bool
Error error
SyncedParent string // If non-empty, parent was merged and we synced to this new parent
WorktreePath string // Path to the worktree (useful for conflict resolution)
BehindBy int // Number of commits behind (for branches that need sync with origin/main)
}
RebaseResult represents the result of a rebase operation
type ReparentInfo ¶
ReparentInfo contains info about a branch that was reparented
type SyncCallbacks ¶
type SyncCallbacks struct {
BeforeRebase BeforeRebaseCallback
AfterRebase AfterRebaseCallback
}
SyncCallbacks contains optional callbacks for sync operations
type SyncInfo ¶
type SyncInfo struct {
Branch string
MergedParent string // Non-empty if parent was merged
BehindBy int // Number of commits behind target
BehindParent string // Non-empty if behind a non-main parent
NeedsSync bool // True if branch needs to be synced
}
SyncInfo contains information about a branch that needs syncing
type UpdateResult ¶
type UpdateResult struct {
// Branches that were removed from config because they no longer exist in git
RemovedBranches []string
// Worktrees that were discovered and added to stacks
AddedBranches []*config.Branch
// Branches whose parent was updated based on merge-base analysis
ReparentedBranches []ReparentInfo
}
UpdateResult contains the results of an update operation