Skip to content

Commit d6a2af8

Browse files
author
Stephan Dilly
committed
branch deletion better distinguish local vs remote
1 parent 035870e commit d6a2af8

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

src/app.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ impl App {
768768
sync::discard_lines(CWD, &path, &lines)?;
769769
flags.insert(NeedsUpdate::ALL);
770770
}
771-
Action::DeleteBranch(branch_ref, true) => {
771+
Action::DeleteLocalBranch(branch_ref) => {
772772
if let Err(e) = sync::delete_branch(CWD, &branch_ref)
773773
{
774774
self.queue.push(InternalEvent::ShowErrorMsg(
@@ -778,8 +778,9 @@ impl App {
778778
flags.insert(NeedsUpdate::ALL);
779779
self.select_branch_popup.update_branches()?;
780780
}
781-
Action::DeleteBranch(branch_ref, false) => {
781+
Action::DeleteRemoteBranch(branch_ref) => {
782782
self.queue.push(
783+
//TODO: check if this is correct based on the fix in `c6abbaf`
783784
branch_ref.rsplit('/').next().map_or_else(
784785
|| {
785786
InternalEvent::ShowErrorMsg(format!(

src/components/branchlist.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -659,13 +659,15 @@ impl BranchListComponent {
659659
}
660660

661661
fn delete_branch(&mut self) {
662+
let reference =
663+
self.branches[self.selection as usize].reference.clone();
664+
662665
self.queue.push(InternalEvent::ConfirmAction(
663-
Action::DeleteBranch(
664-
self.branches[self.selection as usize]
665-
.reference
666-
.clone(),
667-
self.local,
668-
),
666+
if self.local {
667+
Action::DeleteLocalBranch(reference)
668+
} else {
669+
Action::DeleteRemoteBranch(reference)
670+
},
669671
));
670672
}
671673
}

src/components/reset.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl ConfirmComponent {
157157
strings::confirm_title_reset(),
158158
strings::confirm_msg_reset_lines(lines.len()),
159159
),
160-
Action::DeleteBranch(branch_ref, true) => (
160+
Action::DeleteLocalBranch(branch_ref) => (
161161
strings::confirm_title_delete_branch(
162162
&self.key_config,
163163
),
@@ -166,7 +166,7 @@ impl ConfirmComponent {
166166
branch_ref,
167167
),
168168
),
169-
Action::DeleteBranch(branch_ref, false) => (
169+
Action::DeleteRemoteBranch(branch_ref) => (
170170
strings::confirm_title_delete_remote_branch(
171171
&self.key_config,
172172
),

src/queue.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ pub enum Action {
3636
ResetLines(String, Vec<DiffLinePosition>),
3737
StashDrop(Vec<CommitId>),
3838
StashPop(CommitId),
39-
DeleteBranch(String, bool),
39+
DeleteLocalBranch(String),
40+
DeleteRemoteBranch(String),
4041
DeleteTag(String),
4142
ForcePush(String, bool),
4243
PullMerge { incoming: usize, rebase: bool },

0 commit comments

Comments
 (0)