Skip to content

Commit 809281f

Browse files
committed
clippy fix
1 parent 347e6e4 commit 809281f

File tree

1 file changed

+53
-50
lines changed

1 file changed

+53
-50
lines changed

src/app.rs

Lines changed: 53 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -966,17 +966,14 @@ impl App {
966966
Ok(flags)
967967
}
968968

969-
#[allow(clippy::too_many_lines)]
970969
fn process_confirmed_action(
971970
&mut self,
972971
action: Action,
973972
flags: &mut NeedsUpdate,
974973
) -> Result<()> {
975974
match action {
976975
Action::Reset(r) => {
977-
if self.status_tab.reset(&r) {
978-
flags.insert(NeedsUpdate::ALL);
979-
}
976+
self.status_tab.reset(&r);
980977
}
981978
Action::StashDrop(_) | Action::StashPop(_) => {
982979
if let Err(e) = self
@@ -987,8 +984,6 @@ impl App {
987984
e.to_string(),
988985
));
989986
}
990-
991-
flags.insert(NeedsUpdate::ALL);
992987
}
993988
Action::ResetHunk(path, hash) => {
994989
sync::reset_hunk(
@@ -997,15 +992,13 @@ impl App {
997992
hash,
998993
Some(self.options.borrow().diff_options()),
999994
)?;
1000-
flags.insert(NeedsUpdate::ALL);
1001995
}
1002996
Action::ResetLines(path, lines) => {
1003997
sync::discard_lines(
1004998
&self.repo.borrow(),
1005999
&path,
10061000
&lines,
10071001
)?;
1008-
flags.insert(NeedsUpdate::ALL);
10091002
}
10101003
Action::DeleteLocalBranch(branch_ref) => {
10111004
if let Err(e) = sync::delete_branch(
@@ -1016,50 +1009,14 @@ impl App {
10161009
e.to_string(),
10171010
));
10181011
}
1019-
flags.insert(NeedsUpdate::ALL);
1012+
10201013
self.select_branch_popup.update_branches()?;
10211014
}
10221015
Action::DeleteRemoteBranch(branch_ref) => {
1023-
self.queue.push(
1024-
//TODO: check if this is correct based on the fix in `c6abbaf`
1025-
branch_ref.rsplit('/').next().map_or_else(
1026-
|| {
1027-
InternalEvent::ShowErrorMsg(format!(
1028-
"Failed to find the branch name in {branch_ref}"
1029-
))
1030-
},
1031-
|name| {
1032-
InternalEvent::Push(
1033-
name.to_string(),
1034-
PushType::Branch,
1035-
false,
1036-
true,
1037-
)
1038-
},
1039-
),
1040-
);
1041-
flags.insert(NeedsUpdate::ALL);
1042-
self.select_branch_popup.update_branches()?;
1016+
self.delete_remote_branch(&branch_ref)?;
10431017
}
10441018
Action::DeleteTag(tag_name) => {
1045-
if let Err(error) =
1046-
sync::delete_tag(&self.repo.borrow(), &tag_name)
1047-
{
1048-
self.queue.push(InternalEvent::ShowErrorMsg(
1049-
error.to_string(),
1050-
));
1051-
} else {
1052-
let remote = sync::get_default_remote(
1053-
&self.repo.borrow(),
1054-
)?;
1055-
1056-
self.queue.push(InternalEvent::ConfirmAction(
1057-
Action::DeleteRemoteTag(tag_name, remote),
1058-
));
1059-
1060-
flags.insert(NeedsUpdate::ALL);
1061-
self.tags_popup.update_tags()?;
1062-
}
1019+
self.delete_tag(tag_name)?;
10631020
}
10641021
Action::DeleteRemoteTag(tag_name, _remote) => {
10651022
self.queue.push(InternalEvent::Push(
@@ -1079,18 +1036,64 @@ impl App {
10791036
}
10801037
Action::PullMerge { rebase, .. } => {
10811038
self.pull_popup.try_conflict_free_merge(rebase);
1082-
flags.insert(NeedsUpdate::ALL);
10831039
}
10841040
Action::AbortRevert | Action::AbortMerge => {
10851041
self.status_tab.revert_pending_state();
1086-
flags.insert(NeedsUpdate::ALL);
10871042
}
10881043
Action::AbortRebase => {
10891044
self.status_tab.abort_rebase();
1090-
flags.insert(NeedsUpdate::ALL);
10911045
}
10921046
};
10931047

1048+
flags.insert(NeedsUpdate::ALL);
1049+
1050+
Ok(())
1051+
}
1052+
1053+
fn delete_tag(&mut self, tag_name: String) -> Result<()> {
1054+
if let Err(error) =
1055+
sync::delete_tag(&self.repo.borrow(), &tag_name)
1056+
{
1057+
self.queue
1058+
.push(InternalEvent::ShowErrorMsg(error.to_string()));
1059+
} else {
1060+
let remote =
1061+
sync::get_default_remote(&self.repo.borrow())?;
1062+
1063+
self.queue.push(InternalEvent::ConfirmAction(
1064+
Action::DeleteRemoteTag(tag_name, remote),
1065+
));
1066+
1067+
self.tags_popup.update_tags()?;
1068+
};
1069+
Ok(())
1070+
}
1071+
1072+
fn delete_remote_branch(
1073+
&mut self,
1074+
branch_ref: &str,
1075+
) -> Result<()> {
1076+
self.queue.push(
1077+
//TODO: check if this is correct based on the fix in `c6abbaf`
1078+
branch_ref.rsplit('/').next().map_or_else(
1079+
|| {
1080+
InternalEvent::ShowErrorMsg(format!(
1081+
"Failed to find the branch name in {branch_ref}"
1082+
))
1083+
},
1084+
|name| {
1085+
InternalEvent::Push(
1086+
name.to_string(),
1087+
PushType::Branch,
1088+
false,
1089+
true,
1090+
)
1091+
},
1092+
),
1093+
);
1094+
1095+
self.select_branch_popup.update_branches()?;
1096+
10941097
Ok(())
10951098
}
10961099

0 commit comments

Comments
 (0)