pub struct Stack {
pub branches: Vec<StackBranch>,
pub merged: Vec<MergedBranch>,
}Expand description
A stack of dependent branches forming a PR chain.
Fields§
§branches: Vec<StackBranch>Ordered list of branches from base to tip.
merged: Vec<MergedBranch>Branches that have been merged (for preserving history in PR comments).
Implementations§
Source§impl Stack
impl Stack
Sourcepub fn find_branch(&self, name: &str) -> Option<&StackBranch>
pub fn find_branch(&self, name: &str) -> Option<&StackBranch>
Find a branch by name.
Sourcepub fn find_branch_mut(&mut self, name: &str) -> Option<&mut StackBranch>
pub fn find_branch_mut(&mut self, name: &str) -> Option<&mut StackBranch>
Find a branch by name (mutable).
Sourcepub fn add_branch(&mut self, branch: StackBranch)
pub fn add_branch(&mut self, branch: StackBranch)
Add a new branch to the stack.
Sourcepub fn remove_branch(&mut self, name: &str) -> Option<StackBranch>
pub fn remove_branch(&mut self, name: &str) -> Option<StackBranch>
Remove a branch from the stack.
Sourcepub fn mark_merged(&mut self, name: &str) -> Option<StackBranch>
pub fn mark_merged(&mut self, name: &str) -> Option<StackBranch>
Mark a branch as merged, moving it from active to merged list.
This preserves the branch info for stack comment history, including the original parent for ancestry chain traversal. Returns the removed branch if found.
Sourcepub fn find_merged(&self, name: &str) -> Option<&MergedBranch>
pub fn find_merged(&self, name: &str) -> Option<&MergedBranch>
Find a merged branch by name.
Sourcepub fn find_merged_by_pr(&self, pr: u64) -> Option<&MergedBranch>
pub fn find_merged_by_pr(&self, pr: u64) -> Option<&MergedBranch>
Find a merged branch by PR number.
Sourcepub fn clear_merged_if_empty(&mut self)
pub fn clear_merged_if_empty(&mut self)
Clear merged branches when stack is empty.
This should be called after merge operations to clean up when the entire stack has been merged.
Sourcepub fn children_of(&self, name: &str) -> Vec<&StackBranch>
pub fn children_of(&self, name: &str) -> Vec<&StackBranch>
Get all children of a branch.
Sourcepub fn descendants(&self, name: &str) -> Vec<&StackBranch>
pub fn descendants(&self, name: &str) -> Vec<&StackBranch>
Get all descendants of a branch in topological order (parents before children).
This includes children, grandchildren, etc. The branch itself is NOT included.
Sourcepub fn ancestry(&self, name: &str) -> Vec<&StackBranch>
pub fn ancestry(&self, name: &str) -> Vec<&StackBranch>
Get the ancestry chain for a branch (from root to the branch).
Sourcepub fn would_create_cycle(&self, branch: &str, new_parent: &str) -> bool
pub fn would_create_cycle(&self, branch: &str, new_parent: &str) -> bool
Check if reparenting branch to new_parent would create a cycle.
A cycle would occur if the new parent is a descendant of the branch (e.g., setting A’s parent to B when B is already a child of A).
Sourcepub fn reparent(&mut self, branch: &str, new_parent: Option<&str>) -> Result<()>
pub fn reparent(&mut self, branch: &str, new_parent: Option<&str>) -> Result<()>
Reparent a branch to a new parent.
Updates the parent field of the specified branch. Does not perform any git operations - the caller is responsible for rebasing.
§Errors
Returns an error if the branch is not found or if the reparent would create a cycle.