Skip to content

Commit 5b5cc37

Browse files
committed
feat: choose delete or rebase approach when updating branches
1 parent 0cc94b8 commit 5b5cc37

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

crates/but/src/base/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,20 @@ pub fn handle(cmd: &Subcommands, project: &Project, json: bool) -> anyhow::Resul
125125
} else {
126126
println!("🔄 Updating branches...");
127127
let mut resolutions = vec![];
128-
for (id, _status) in statuses {
128+
for (id, status) in statuses {
129+
let approach = if status
130+
.branch_statuses
131+
.iter()
132+
.all(|s| s.status == gitbutler_branch_actions::upstream_integration::BranchStatus::Integrated)
133+
&& status.tree_status != gitbutler_branch_actions::upstream_integration::TreeStatus::Conflicted
134+
{
135+
ResolutionApproach::Delete
136+
} else {
137+
ResolutionApproach::Rebase
138+
};
129139
let resolution = Resolution {
130140
branch_id: id, // This is StackId
131-
approach: ResolutionApproach::Rebase,
141+
approach,
132142
delete_integrated_branches: true,
133143
force_integrated_branches: vec![],
134144
};

0 commit comments

Comments
 (0)