Skip to content

Commit 747bc80

Browse files
committed
Merge master and fix clippy issues
1 parent fefd64a commit 747bc80

31 files changed

+74
-78
lines changed

asyncgit/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ pub type Result<T> = std::result::Result<T, Error>;
8383

8484
impl<T> From<std::sync::PoisonError<T>> for Error {
8585
fn from(error: std::sync::PoisonError<T>) -> Self {
86-
Self::Generic(format!("poison error: {}", error))
86+
Self::Generic(format!("poison error: {error}"))
8787
}
8888
}
8989

9090
impl<T> From<crossbeam_channel::SendError<T>> for Error {
9191
fn from(error: crossbeam_channel::SendError<T>) -> Self {
92-
Self::Generic(format!("send error: {}", error))
92+
Self::Generic(format!("send error: {error}"))
9393
}
9494
}

asyncgit/src/sync/branch/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ pub(crate) fn branch_set_upstream(
206206

207207
if branch.upstream().is_err() {
208208
let remote = get_default_remote_in_repo(repo)?;
209-
let upstream_name = format!("{}/{}", remote, branch_name);
209+
let upstream_name = format!("{remote}/{branch_name}");
210210
branch.set_upstream(Some(upstream_name.as_str()))?;
211211
}
212212

asyncgit/src/sync/commit_details.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl CommitMessage {
6060
///
6161
pub fn combine(self) -> String {
6262
if let Some(body) = self.body {
63-
format!("{}\n{}", self.subject, body)
63+
format!("{}\n{body}", self.subject)
6464
} else {
6565
self.subject
6666
}

asyncgit/src/sync/hooks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl HookPaths {
8787
} else {
8888
let err = String::from_utf8_lossy(&output.stderr);
8989
let out = String::from_utf8_lossy(&output.stdout);
90-
let formatted = format!("{}{}", out, err);
90+
let formatted = format!("{out}{err}");
9191

9292
Ok(HookResult::NotOk(formatted))
9393
}

asyncgit/src/sync/remotes/push.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub fn push_raw(
164164
};
165165

166166
let branch_name =
167-
format!("{}refs/{}/{}", branch_modifier, ref_type, branch);
167+
format!("{branch_modifier}refs/{ref_type}/{branch}");
168168
remote.push(&[branch_name.as_str()], Some(&mut options))?;
169169

170170
if let Some((reference, msg)) =

asyncgit/src/sync/remotes/tags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub fn tags_missing_remote(
8989

9090
let mut local_tags = tags
9191
.iter()
92-
.filter_map(|tag| tag.map(|tag| format!("refs/tags/{}", tag)))
92+
.filter_map(|tag| tag.map(|tag| format!("refs/tags/{tag}")))
9393
.collect::<HashSet<_>>();
9494
let remote_tags =
9595
remote_tag_refs(repo_path, remote, basic_credential)?;

src/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ impl App {
448448

449449
if let Err(e) = result {
450450
let msg =
451-
format!("failed to launch editor:\n{}", e);
451+
format!("failed to launch editor:\n{e}");
452452
log::error!("{}", msg.as_str());
453453
self.msg.show_error(msg.as_str())?;
454454
}

src/components/branchlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ impl BranchListComponent {
609609
};
610610

611611
let span_prefix = Span::styled(
612-
format!("{}{} ", is_head_str, upstream_tracking_str),
612+
format!("{is_head_str}{upstream_tracking_str} "),
613613
theme.commit_author(selected),
614614
);
615615
let span_hash = Span::styled(

src/components/commit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl CommitComponent {
9494

9595
fn draw_branch_name<B: Backend>(&self, f: &mut Frame<B>) {
9696
if let Some(name) = self.git_branch_name.last() {
97-
let w = Paragraph::new(format!("{{{}}}", name))
97+
let w = Paragraph::new(format!("{{{name}}}"))
9898
.alignment(Alignment::Right);
9999

100100
let rect = {

src/components/commitlist.rs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::needless_pass_by_value)]
12
use super::utils::logitems::{ItemBatch, LogEntry};
23
use crate::{
34
components::{
@@ -191,7 +192,7 @@ impl CommitList {
191192
format!("{}^..{}", f.hash_short, l.hash_short);
192193
if let Err(e) = crate::clipboard::copy_string(&yank) {
193194
self.queue.push(InternalEvent::ShowErrorMsg(
194-
copy_fail(e.to_string()),
195+
copy_fail(&e.to_string()),
195196
));
196197
return Err(e);
197198
}
@@ -215,7 +216,7 @@ impl CommitList {
215216

216217
if let Err(e) = crate::clipboard::copy_string(&separate) {
217218
self.queue.push(InternalEvent::ShowErrorMsg(
218-
copy_fail(e.to_string()),
219+
copy_fail(&e.to_string()),
219220
));
220221
return Err(e);
221222
}
@@ -238,7 +239,7 @@ impl CommitList {
238239
crate::clipboard::copy_string(&e.hash_short)
239240
{
240241
self.queue.push(InternalEvent::ShowErrorMsg(
241-
copy_fail(e.to_string()),
242+
copy_fail(&e.to_string()),
242243
));
243244
return Err(e);
244245
}
@@ -255,7 +256,7 @@ impl CommitList {
255256
crate::clipboard::copy_string(&e.hash_short)
256257
{
257258
self.queue.push(InternalEvent::ShowErrorMsg(
258-
copy_fail(e.to_string()),
259+
copy_fail(&e.to_string()),
259260
));
260261
return Err(e);
261262
}
@@ -406,7 +407,7 @@ impl CommitList {
406407
txt.push(splitter.clone());
407408

408409
let author_width =
409-
(width.saturating_sub(19) / 3).max(3).min(20);
410+
(width.saturating_sub(19) / 3).clamp(3, 20);
410411
let author = string_width_align(&e.author, author_width);
411412

412413
// commit author
@@ -418,18 +419,14 @@ impl CommitList {
418419
txt.push(splitter.clone());
419420

420421
// commit tags
421-
if let Some(tags) = tags {
422-
txt.push(splitter.clone());
423-
txt.push(Span::styled(tags, theme.tags(selected)));
424-
}
425-
426-
if let Some(branches) = branches {
427-
txt.push(splitter.clone());
428-
txt.push(Span::styled(
429-
branches,
430-
theme.branch(selected, true),
431-
));
432-
}
422+
txt.push(Span::styled(
423+
Cow::from(
424+
tags.map_or_else(String::new, |tags| {
425+
format!(" {tags}")
426+
}),
427+
),
428+
theme.tags(selected),
429+
));
433430

434431
txt.push(splitter);
435432

@@ -439,7 +436,7 @@ impl CommitList {
439436

440437
// commit msg
441438
txt.push(Span::styled(
442-
format!("{:w$}", &e.msg, w = message_width),
439+
format!("{:message_width$}", &e.msg),
443440
theme.text(true, selected),
444441
));
445442

@@ -474,7 +471,7 @@ impl CommitList {
474471
let branches = self.branches.get(&e.id).map(|names| {
475472
names
476473
.iter()
477-
.map(|name| format!("{{{}}}", name))
474+
.map(|name| format!("{{{name}}}"))
478475
.join(" ")
479476
});
480477

@@ -542,7 +539,7 @@ impl DrawableComponent for CommitList {
542539
));
543540

544541
let branch_post_fix =
545-
self.branch.as_ref().map(|b| format!("- {{{}}}", b));
542+
self.branch.as_ref().map(|b| format!("- {{{b}}}"));
546543

547544
let title = format!(
548545
"{} {}/{} {}",

0 commit comments

Comments
 (0)