Skip to content

Commit 61b2706

Browse files
author
Naseschwarz
committed
Fix clippy remarks
1 parent fbbbe74 commit 61b2706

File tree

20 files changed

+64
-50
lines changed

20 files changed

+64
-50
lines changed

asyncgit/src/sync/branch/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ pub fn config_is_pull_rebase(repo_path: &RepoPath) -> Result<bool> {
271271
let value =
272272
rebase.value().map(String::from).unwrap_or_default();
273273
return Ok(value == "true");
274-
};
274+
}
275275

276276
Ok(false)
277277
}
@@ -701,7 +701,7 @@ mod tests_branches {
701701
&root.as_os_str().to_str().unwrap().into();
702702

703703
let upstream_merge_res =
704-
get_branch_upstream_merge(&repo_path, "master");
704+
get_branch_upstream_merge(repo_path, "master");
705705
assert!(
706706
upstream_merge_res.is_ok_and(|v| v.as_ref().is_none())
707707
);
@@ -721,12 +721,12 @@ mod tests_branches {
721721
config
722722
.set_str(
723723
&format!("branch.{branch_name}.merge"),
724-
&upstrem_merge,
724+
upstrem_merge,
725725
)
726726
.expect("fail set branch merge config");
727727

728728
let upstream_merge_res =
729-
get_branch_upstream_merge(&repo_path, &branch_name);
729+
get_branch_upstream_merge(repo_path, branch_name);
730730
assert!(upstream_merge_res
731731
.as_ref()
732732
.is_ok_and(|v| v.as_ref().is_some()));

asyncgit/src/sync/remotes/push.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::fmt::Write;
2+
13
use crate::{
24
error::{Error, Result},
35
progress::ProgressPercent,
@@ -182,7 +184,8 @@ pub fn push_raw(
182184
if let Ok(Some(branch_upstream_merge)) =
183185
get_branch_upstream_merge(repo_path, branch)
184186
{
185-
push_ref.push_str(&format!(":{branch_upstream_merge}"));
187+
write!(&mut push_ref, ":{branch_upstream_merge}")
188+
.map_err(|e| Error::Generic(e.to_string()))?;
186189
}
187190
}
188191

@@ -289,7 +292,7 @@ mod tests {
289292

290293
// Attempt force push,
291294
// should work as it forces the push through
292-
assert!(!push_branch(
295+
assert!(push_branch(
293296
&tmp_other_repo_dir.path().to_str().unwrap().into(),
294297
"origin",
295298
"master",
@@ -298,7 +301,7 @@ mod tests {
298301
None,
299302
None,
300303
)
301-
.is_err());
304+
.is_ok());
302305
}
303306

304307
#[test]

asyncgit/src/sync/stash.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ mod tests {
144144
let repo_path: &RepoPath =
145145
&root.as_os_str().to_str().unwrap().into();
146146

147-
assert!(!stash_save(repo_path, None, true, false).is_ok());
147+
assert!(stash_save(repo_path, None, true, false).is_err());
148148

149149
assert!(get_stashes(repo_path).unwrap().is_empty());
150150
}

asyncgit/src/sync/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ mod tests {
242242
let root = repo.path().parent().unwrap();
243243
let repo_path = root.as_os_str().to_str().unwrap();
244244

245-
assert!(!stage_add_file(&repo_path.into(), file_path).is_ok());
245+
assert!(stage_add_file(&repo_path.into(), file_path).is_err());
246246
}
247247

248248
#[test]
@@ -440,7 +440,7 @@ mod tests {
440440
let repo_path: &RepoPath =
441441
&root.as_os_str().to_str().unwrap().into();
442442

443-
assert!(!get_head(repo_path).is_ok());
443+
assert!(get_head(repo_path).is_err());
444444

445445
Ok(())
446446
}

filetreelist/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl TreeItemInfo {
5555
Path::new(
5656
self.full_path
5757
.components()
58-
.last()
58+
.next_back()
5959
.and_then(|c| c.as_os_str().to_str())
6060
.unwrap_or_default(),
6161
)

filetreelist/src/treeitems_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl<'a> Iterator for TreeItemsIterator<'a> {
3535
*i += 1;
3636
} else {
3737
self.increments = Some(0);
38-
};
38+
}
3939

4040
loop {
4141
if !init {

src/app.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl App {
275275
3 => self.stashing_tab.draw(f, chunks_main[1])?,
276276
4 => self.stashlist_tab.draw(f, chunks_main[1])?,
277277
_ => bail!("unknown tab"),
278-
};
278+
}
279279
}
280280

281281
self.draw_popups(f)?;
@@ -905,7 +905,7 @@ impl App {
905905
InternalEvent::CommitSearch(options) => {
906906
self.revlog.search(options);
907907
}
908-
};
908+
}
909909

910910
Ok(flags)
911911
}
@@ -997,7 +997,7 @@ impl App {
997997
undo_last_commit(&self.repo.borrow())
998998
);
999999
}
1000-
};
1000+
}
10011001

10021002
flags.insert(NeedsUpdate::ALL);
10031003

@@ -1019,7 +1019,7 @@ impl App {
10191019
));
10201020

10211021
self.tags_popup.update_tags()?;
1022-
};
1022+
}
10231023
Ok(())
10241024
}
10251025

src/args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ fn setup_logging(path_override: Option<PathBuf>) -> Result<()> {
139139
path
140140
};
141141

142-
println!("Logging enabled. Log written to: {path:?}");
142+
println!("Logging enabled. Log written to: {}", path.display());
143143

144144
WriteLogger::init(
145145
LevelFilter::Trace,

src/components/changes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl ChangesComponent {
9292
&self.repo.borrow(),
9393
path,
9494
)?,
95-
};
95+
}
9696
} else {
9797
let config =
9898
self.options.borrow().status_show_untracked();

src/components/commitlist.rs

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -490,24 +490,36 @@ impl CommitList {
490490
txt.push(splitter.clone());
491491
}
492492

493-
let style_hash = normal
494-
.then(|| theme.commit_hash(selected))
495-
.unwrap_or_else(|| theme.commit_unhighlighted());
496-
let style_time = normal
497-
.then(|| theme.commit_time(selected))
498-
.unwrap_or_else(|| theme.commit_unhighlighted());
499-
let style_author = normal
500-
.then(|| theme.commit_author(selected))
501-
.unwrap_or_else(|| theme.commit_unhighlighted());
502-
let style_tags = normal
503-
.then(|| theme.tags(selected))
504-
.unwrap_or_else(|| theme.commit_unhighlighted());
505-
let style_branches = normal
506-
.then(|| theme.branch(selected, true))
507-
.unwrap_or_else(|| theme.commit_unhighlighted());
508-
let style_msg = normal
509-
.then(|| theme.text(true, selected))
510-
.unwrap_or_else(|| theme.commit_unhighlighted());
493+
let style_hash = if normal {
494+
theme.commit_hash(selected)
495+
} else {
496+
theme.commit_unhighlighted()
497+
};
498+
let style_time = if normal {
499+
theme.commit_time(selected)
500+
} else {
501+
theme.commit_unhighlighted()
502+
};
503+
let style_author = if normal {
504+
theme.commit_author(selected)
505+
} else {
506+
theme.commit_unhighlighted()
507+
};
508+
let style_tags = if normal {
509+
theme.tags(selected)
510+
} else {
511+
theme.commit_unhighlighted()
512+
};
513+
let style_branches = if normal {
514+
theme.branch(selected, true)
515+
} else {
516+
theme.commit_unhighlighted()
517+
};
518+
let style_msg = if normal {
519+
theme.text(true, selected)
520+
} else {
521+
theme.commit_unhighlighted()
522+
};
511523

512524
// commit hash
513525
txt.push(Span::styled(Cow::from(&*e.hash_short), style_hash));

0 commit comments

Comments
 (0)