Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion packages/core/src/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,21 @@ export class StackManager {
}

async deleteBranch(branchName: string, force = false): Promise<void> {
// Remove from tracking first
// Reparent children to the deleted branch's parent
const relationship = this.state.getBranchRelationship(branchName);
const parent = relationship?.parent ?? this.getTrunk();
const children = this.state.getChildren(branchName);
for (const child of children) {
const childRel = this.state.getBranchRelationship(child);
if (childRel) {
this.state.setBranchRelationship(child, {
...childRel,
parent,
});
}
}

// Remove from tracking
this.state.removeBranchRelationship(branchName);

// Then delete the git branch
Expand Down