branch deletion better distinguish local vs remote

This commit is contained in:
Stephan Dilly 2021-10-13 11:55:21 +02:00
parent 035870e52f
commit d6a2af89ee
4 changed files with 15 additions and 11 deletions

View file

@ -768,7 +768,7 @@ impl App {
sync::discard_lines(CWD, &path, &lines)?; sync::discard_lines(CWD, &path, &lines)?;
flags.insert(NeedsUpdate::ALL); flags.insert(NeedsUpdate::ALL);
} }
Action::DeleteBranch(branch_ref, true) => { Action::DeleteLocalBranch(branch_ref) => {
if let Err(e) = sync::delete_branch(CWD, &branch_ref) if let Err(e) = sync::delete_branch(CWD, &branch_ref)
{ {
self.queue.push(InternalEvent::ShowErrorMsg( self.queue.push(InternalEvent::ShowErrorMsg(
@ -778,8 +778,9 @@ impl App {
flags.insert(NeedsUpdate::ALL); flags.insert(NeedsUpdate::ALL);
self.select_branch_popup.update_branches()?; self.select_branch_popup.update_branches()?;
} }
Action::DeleteBranch(branch_ref, false) => { Action::DeleteRemoteBranch(branch_ref) => {
self.queue.push( self.queue.push(
//TODO: check if this is correct based on the fix in `c6abbaf`
branch_ref.rsplit('/').next().map_or_else( branch_ref.rsplit('/').next().map_or_else(
|| { || {
InternalEvent::ShowErrorMsg(format!( InternalEvent::ShowErrorMsg(format!(

View file

@ -659,13 +659,15 @@ impl BranchListComponent {
} }
fn delete_branch(&mut self) { fn delete_branch(&mut self) {
let reference =
self.branches[self.selection as usize].reference.clone();
self.queue.push(InternalEvent::ConfirmAction( self.queue.push(InternalEvent::ConfirmAction(
Action::DeleteBranch( if self.local {
self.branches[self.selection as usize] Action::DeleteLocalBranch(reference)
.reference } else {
.clone(), Action::DeleteRemoteBranch(reference)
self.local, },
),
)); ));
} }
} }

View file

@ -157,7 +157,7 @@ impl ConfirmComponent {
strings::confirm_title_reset(), strings::confirm_title_reset(),
strings::confirm_msg_reset_lines(lines.len()), strings::confirm_msg_reset_lines(lines.len()),
), ),
Action::DeleteBranch(branch_ref, true) => ( Action::DeleteLocalBranch(branch_ref) => (
strings::confirm_title_delete_branch( strings::confirm_title_delete_branch(
&self.key_config, &self.key_config,
), ),
@ -166,7 +166,7 @@ impl ConfirmComponent {
branch_ref, branch_ref,
), ),
), ),
Action::DeleteBranch(branch_ref, false) => ( Action::DeleteRemoteBranch(branch_ref) => (
strings::confirm_title_delete_remote_branch( strings::confirm_title_delete_remote_branch(
&self.key_config, &self.key_config,
), ),

View file

@ -36,7 +36,8 @@ pub enum Action {
ResetLines(String, Vec<DiffLinePosition>), ResetLines(String, Vec<DiffLinePosition>),
StashDrop(Vec<CommitId>), StashDrop(Vec<CommitId>),
StashPop(CommitId), StashPop(CommitId),
DeleteBranch(String, bool), DeleteLocalBranch(String),
DeleteRemoteBranch(String),
DeleteTag(String), DeleteTag(String),
ForcePush(String, bool), ForcePush(String, bool),
PullMerge { incoming: usize, rebase: bool }, PullMerge { incoming: usize, rebase: bool },