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
"{} {}/{} {}",

src/components/create_branch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl CreateBranchComponent {
142142
Err(e) => {
143143
log::error!("create branch: {}", e,);
144144
self.queue.push(InternalEvent::ShowErrorMsg(
145-
format!("create branch error:\n{}", e,),
145+
format!("create branch error:\n{e}",),
146146
));
147147
}
148148
}

src/components/diff.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl DiffComponent {
198198

199199
fn move_selection(&mut self, move_type: ScrollType) {
200200
if let Some(diff) = &self.diff {
201-
let max = diff.lines.saturating_sub(1) as usize;
201+
let max = diff.lines.saturating_sub(1);
202202

203203
let new_start = match move_type {
204204
ScrollType::Down => {
@@ -229,7 +229,7 @@ impl DiffComponent {
229229

230230
fn update_selection(&mut self, new_start: usize) {
231231
if let Some(diff) = &self.diff {
232-
let max = diff.lines.saturating_sub(1) as usize;
232+
let max = diff.lines.saturating_sub(1);
233233
let new_start = cmp::min(max, new_start);
234234
self.selection = Selection::Single(new_start);
235235
self.selected_hunk =
@@ -303,9 +303,8 @@ impl DiffComponent {
303303
if let Some(diff) = &self.diff {
304304
if diff.hunks.is_empty() {
305305
let is_positive = diff.size_delta >= 0;
306-
let delta_byte_size = ByteSize::b(
307-
diff.size_delta.unsigned_abs() as u64,
308-
);
306+
let delta_byte_size =
307+
ByteSize::b(diff.size_delta.unsigned_abs());
309308
let sign = if is_positive { "+" } else { "-" };
310309
res.extend(vec![Spans::from(vec![
311310
Span::raw(Cow::from("size: ")),
@@ -378,7 +377,7 @@ impl DiffComponent {
378377
.selection
379378
.contains(line_cursor),
380379
hunk_selected,
381-
i == hunk_len as usize - 1,
380+
i == hunk_len - 1,
382381
&self.theme,
383382
));
384383
lines_added += 1;

src/components/file_revlog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl FileRevlogComponent {
231231
let commits = get_commits_info(
232232
&self.repo_path.borrow(),
233233
&git_log.get_slice(start, SLICE_SIZE)?,
234-
self.current_width.get() as usize,
234+
self.current_width.get(),
235235
);
236236

237237
if let Ok(commits) = commits {

src/components/options_popup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl OptionsPopupComponent {
134134
self.theme.text(true, false),
135135
),
136136
Span::styled(
137-
format!("{:^w$}", value, w = half),
137+
format!("{value:^half$}"),
138138
self.theme.text(true, selected),
139139
),
140140
]));

src/components/pull.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl PullComponent {
118118
self.pending = false;
119119
self.hide();
120120
self.queue.push(InternalEvent::ShowErrorMsg(
121-
format!("fetch failed:\n{}", error),
121+
format!("fetch failed:\n{error}"),
122122
));
123123
}
124124
}

src/components/push.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl PushComponent {
181181
if !self.pending {
182182
if let Some(err) = self.git_push.last_result()? {
183183
self.queue.push(InternalEvent::ShowErrorMsg(
184-
format!("push failed:\n{}", err),
184+
format!("push failed:\n{err}"),
185185
));
186186
}
187187
self.hide();

src/components/push_tags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl PushTagsComponent {
123123
if !self.pending {
124124
if let Some(err) = self.git_push.last_result()? {
125125
self.queue.push(InternalEvent::ShowErrorMsg(
126-
format!("push tags failed:\n{}", err),
126+
format!("push tags failed:\n{err}"),
127127
));
128128
}
129129
self.hide();

src/components/rename_branch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl RenameBranchComponent {
144144
Err(e) => {
145145
log::error!("create branch: {}", e,);
146146
self.queue.push(InternalEvent::ShowErrorMsg(
147-
format!("rename branch error:\n{}", e,),
147+
format!("rename branch error:\n{e}",),
148148
));
149149
}
150150
}

src/components/status_tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl StatusTreeComponent {
167167
let indent_str = if indent == 0 {
168168
String::new()
169169
} else {
170-
format!("{:w$}", " ", w = (indent as usize) * 2)
170+
format!("{:w$}", " ", w = indent * 2)
171171
};
172172

173173
if !visible {
@@ -192,7 +192,7 @@ impl StatusTreeComponent {
192192
w = width as usize
193193
)
194194
} else {
195-
format!("{} {}{}", status_char, indent_str, file)
195+
format!("{status_char} {indent_str}{file}")
196196
};
197197

198198
Some(Span::styled(

src/components/submodules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ impl SubmodulesListComponent {
387387
);
388388

389389
let span_name = Span::styled(
390-
format!("{:w$} ", module_path, w = name_length),
390+
format!("{module_path:name_length$} "),
391391
theme.text(true, selected),
392392
);
393393

src/components/tag_commit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl TagCommitComponent {
194194

195195
log::error!("e: {}", e,);
196196
self.queue.push(InternalEvent::ShowErrorMsg(
197-
format!("tag error:\n{}", e,),
197+
format!("tag error:\n{e}",),
198198
));
199199
}
200200
}

src/components/textinput.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ impl TextInputComponent {
305305
fn draw_char_count<B: Backend>(&self, f: &mut Frame<B>, r: Rect) {
306306
let count = self.msg.len();
307307
if count > 0 {
308-
let w = Paragraph::new(format!("[{} chars]", count))
308+
let w = Paragraph::new(format!("[{count} chars]"))
309309
.alignment(Alignment::Right);
310310

311311
let mut rect = {

src/components/utils/logitems.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl LogEntry {
5555
} else {
5656
format!("{:0>2}m ago", delta.num_minutes())
5757
};
58-
format!("{: <10}", delta_str)
58+
format!("{delta_str: <10}")
5959
} else if self.time.date() == now.date() {
6060
self.time.format("%T ").to_string()
6161
} else {

src/components/utils/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ pub fn string_width_align(s: &str, width: usize) -> String {
4747
if (len >= width_wo_postfix && len <= width)
4848
|| (len <= width_wo_postfix)
4949
{
50-
format!("{:w$}", s, w = width)
50+
format!("{s:width$}")
5151
} else {
5252
let mut s = s.to_string();
5353
s.truncate(find_truncate_point(&s, width_wo_postfix));
54-
format!("{}{}", s, POSTFIX)
54+
format!("{s}{POSTFIX}")
5555
}
5656
}
5757

src/components/utils/statustree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ impl StatusTree {
352352
*collapsed = true;
353353
}
354354

355-
let path = format!("{}/", path);
355+
let path = format!("{path}/");
356356

357357
for i in index + 1..self.tree.len() {
358358
let item = &mut self.tree[i];
@@ -373,7 +373,7 @@ impl StatusTree {
373373
*collapsed = false;
374374
}
375375

376-
let path = format!("{}/", path);
376+
let path = format!("{path}/");
377377

378378
self.update_visibility(
379379
Some(path.as_str()),

0 commit comments

Comments
 (0)