From 809281f1ab3e2bf8ce646554bfecec8d82658c32 Mon Sep 17 00:00:00 2001 From: extrawurst Date: Wed, 16 Aug 2023 12:43:41 +0200 Subject: [PATCH] clippy fix --- src/app.rs | 103 +++++++++++++++++++++++++++-------------------------- 1 file changed, 53 insertions(+), 50 deletions(-) diff --git a/src/app.rs b/src/app.rs index 848c4e6b..9751b096 100644 --- a/src/app.rs +++ b/src/app.rs @@ -966,7 +966,6 @@ impl App { Ok(flags) } - #[allow(clippy::too_many_lines)] fn process_confirmed_action( &mut self, action: Action, @@ -974,9 +973,7 @@ impl App { ) -> Result<()> { match action { Action::Reset(r) => { - if self.status_tab.reset(&r) { - flags.insert(NeedsUpdate::ALL); - } + self.status_tab.reset(&r); } Action::StashDrop(_) | Action::StashPop(_) => { if let Err(e) = self @@ -987,8 +984,6 @@ impl App { e.to_string(), )); } - - flags.insert(NeedsUpdate::ALL); } Action::ResetHunk(path, hash) => { sync::reset_hunk( @@ -997,7 +992,6 @@ impl App { hash, Some(self.options.borrow().diff_options()), )?; - flags.insert(NeedsUpdate::ALL); } Action::ResetLines(path, lines) => { sync::discard_lines( @@ -1005,7 +999,6 @@ impl App { &path, &lines, )?; - flags.insert(NeedsUpdate::ALL); } Action::DeleteLocalBranch(branch_ref) => { if let Err(e) = sync::delete_branch( @@ -1016,50 +1009,14 @@ impl App { e.to_string(), )); } - flags.insert(NeedsUpdate::ALL); + self.select_branch_popup.update_branches()?; } Action::DeleteRemoteBranch(branch_ref) => { - self.queue.push( - //TODO: check if this is correct based on the fix in `c6abbaf` - branch_ref.rsplit('/').next().map_or_else( - || { - InternalEvent::ShowErrorMsg(format!( - "Failed to find the branch name in {branch_ref}" - )) - }, - |name| { - InternalEvent::Push( - name.to_string(), - PushType::Branch, - false, - true, - ) - }, - ), - ); - flags.insert(NeedsUpdate::ALL); - self.select_branch_popup.update_branches()?; + self.delete_remote_branch(&branch_ref)?; } Action::DeleteTag(tag_name) => { - if let Err(error) = - sync::delete_tag(&self.repo.borrow(), &tag_name) - { - self.queue.push(InternalEvent::ShowErrorMsg( - error.to_string(), - )); - } else { - let remote = sync::get_default_remote( - &self.repo.borrow(), - )?; - - self.queue.push(InternalEvent::ConfirmAction( - Action::DeleteRemoteTag(tag_name, remote), - )); - - flags.insert(NeedsUpdate::ALL); - self.tags_popup.update_tags()?; - } + self.delete_tag(tag_name)?; } Action::DeleteRemoteTag(tag_name, _remote) => { self.queue.push(InternalEvent::Push( @@ -1079,18 +1036,64 @@ impl App { } Action::PullMerge { rebase, .. } => { self.pull_popup.try_conflict_free_merge(rebase); - flags.insert(NeedsUpdate::ALL); } Action::AbortRevert | Action::AbortMerge => { self.status_tab.revert_pending_state(); - flags.insert(NeedsUpdate::ALL); } Action::AbortRebase => { self.status_tab.abort_rebase(); - flags.insert(NeedsUpdate::ALL); } }; + flags.insert(NeedsUpdate::ALL); + + Ok(()) + } + + fn delete_tag(&mut self, tag_name: String) -> Result<()> { + if let Err(error) = + sync::delete_tag(&self.repo.borrow(), &tag_name) + { + self.queue + .push(InternalEvent::ShowErrorMsg(error.to_string())); + } else { + let remote = + sync::get_default_remote(&self.repo.borrow())?; + + self.queue.push(InternalEvent::ConfirmAction( + Action::DeleteRemoteTag(tag_name, remote), + )); + + self.tags_popup.update_tags()?; + }; + Ok(()) + } + + fn delete_remote_branch( + &mut self, + branch_ref: &str, + ) -> Result<()> { + self.queue.push( + //TODO: check if this is correct based on the fix in `c6abbaf` + branch_ref.rsplit('/').next().map_or_else( + || { + InternalEvent::ShowErrorMsg(format!( + "Failed to find the branch name in {branch_ref}" + )) + }, + |name| { + InternalEvent::Push( + name.to_string(), + PushType::Branch, + false, + true, + ) + }, + ), + ); + + self.select_branch_popup.update_branches()?; + Ok(()) }