Skip to content

Commit d5cd4c1

Browse files
author
Naseschwarz
committed
Apply clippy fixes
1 parent a35cbf2 commit d5cd4c1

File tree

7 files changed

+44
-35
lines changed

7 files changed

+44
-35
lines changed

asyncgit/src/sync/branch/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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/hooks.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,8 @@ mod tests {
230230
create_hook_in_path(&hooks_folder.join("commit-msg"), hook);
231231

232232
let mut msg = String::from("test");
233-
let res = hooks_commit_msg(
234-
&hooks_folder.to_path_buf().into(),
235-
&mut msg,
236-
)
237-
.unwrap();
233+
let res =
234+
hooks_commit_msg(&hooks_folder.into(), &mut msg).unwrap();
238235
assert_eq!(
239236
res,
240237
HookResult::NotOk(String::from("rejected\n"))

asyncgit/src/sync/remotes/push.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ mod tests {
290290

291291
// Attempt force push,
292292
// should work as it forces the push through
293-
assert!(!push_branch(
293+
assert!(push_branch(
294294
&tmp_other_repo_dir.path().to_str().unwrap().into(),
295295
"origin",
296296
"master",
@@ -299,7 +299,7 @@ mod tests {
299299
None,
300300
None,
301301
)
302-
.is_err());
302+
.is_ok());
303303
}
304304

305305
#[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
}

git2-hooks/src/hookspath.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,8 @@ mod test {
331331
fn test_hookspath_relative() {
332332
assert_eq!(
333333
HookPaths::expand_path(
334-
&Path::new("pre-commit"),
335-
&Path::new("example_git_root"),
334+
Path::new("pre-commit"),
335+
Path::new("example_git_root"),
336336
)
337337
.unwrap(),
338338
Path::new("example_git_root").join("pre-commit")
@@ -346,7 +346,7 @@ mod test {
346346
assert_eq!(
347347
HookPaths::expand_path(
348348
&absolute_hook,
349-
&Path::new("example_git_root"),
349+
Path::new("example_git_root"),
350350
)
351351
.unwrap(),
352352
absolute_hook

src/components/commitlist.rs

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -488,24 +488,36 @@ impl CommitList {
488488
txt.push(splitter.clone());
489489
}
490490

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

510522
// commit hash
511523
txt.push(Span::styled(Cow::from(&*e.hash_short), style_hash));
@@ -898,7 +910,7 @@ mod tests {
898910
impl Default for CommitList {
899911
fn default() -> Self {
900912
Self {
901-
title: String::from("").into_boxed_str(),
913+
title: String::new().into_boxed_str(),
902914
selection: 0,
903915
highlighted_selection: Option::None,
904916
highlights: Option::None,

0 commit comments

Comments
 (0)