Skip to content

Commit

Permalink
fix nightly clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
extrawurst committed Dec 10, 2022
1 parent 7dcf93e commit 289eddd
Show file tree
Hide file tree
Showing 23 changed files with 98 additions and 135 deletions.
9 changes: 4 additions & 5 deletions asyncgit/src/sync/blame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ mod tests {

assert!(matches!(blame_file(repo_path, "foo", None), Err(_)));

File::create(&root.join(file_path))?
.write_all(b"line 1\n")?;
File::create(root.join(file_path))?.write_all(b"line 1\n")?;

stage_add_file(repo_path, file_path)?;
commit(repo_path, "first commit")?;
Expand All @@ -195,7 +194,7 @@ mod tests {

let mut file = OpenOptions::new()
.append(true)
.open(&root.join(file_path))?;
.open(root.join(file_path))?;

file.write(b"line 2\n")?;

Expand Down Expand Up @@ -251,9 +250,9 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

std::fs::create_dir(&root.join("bar")).unwrap();
std::fs::create_dir(root.join("bar")).unwrap();

File::create(&root.join(file_path))
File::create(root.join(file_path))
.unwrap()
.write_all(b"line 1\n")
.unwrap();
Expand Down
16 changes: 8 additions & 8 deletions asyncgit/src/sync/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))
File::create(root.join(file_path))
.unwrap()
.write_all(b"test\nfoo")
.unwrap();
Expand All @@ -177,7 +177,7 @@ mod tests {

assert_eq!(get_statuses(repo_path), (0, 0));

File::create(&root.join(file_path))
File::create(root.join(file_path))
.unwrap()
.write_all(b"test\nfoo")
.unwrap();
Expand All @@ -202,14 +202,14 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path1))?.write_all(b"test1")?;
File::create(root.join(file_path1))?.write_all(b"test1")?;

stage_add_file(repo_path, file_path1)?;
let id = commit(repo_path, "commit msg")?;

assert_eq!(count_commits(&repo, 10), 1);

File::create(&root.join(file_path2))?.write_all(b"test2")?;
File::create(root.join(file_path2))?.write_all(b"test2")?;

stage_add_file(repo_path, file_path2)?;

Expand Down Expand Up @@ -239,7 +239,7 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?
File::create(root.join(file_path))?
.write_all(b"test\nfoo")?;

stage_add_file(repo_path, file_path)?;
Expand Down Expand Up @@ -281,7 +281,7 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?
File::create(root.join(file_path))?
.write_all(b"test\nfoo")?;

stage_add_file(repo_path, file_path)?;
Expand Down Expand Up @@ -315,7 +315,7 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?
File::create(root.join(file_path))?
.write_all(b"test\nfoo")?;

stage_add_file(repo_path, file_path)?;
Expand Down Expand Up @@ -351,7 +351,7 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?
File::create(root.join(file_path))?
.write_all(b"test\nfoo")?;

stage_add_file(repo_path, file_path)?;
Expand Down
2 changes: 1 addition & 1 deletion asyncgit/src/sync/commit_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?.write_all(b"a")?;
File::create(root.join(file_path))?.write_all(b"a")?;
stage_add_file(repo_path, file_path).unwrap();

let msg = invalidstring::invalid_utf8("test msg");
Expand Down
10 changes: 5 additions & 5 deletions asyncgit/src/sync/commit_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?
File::create(root.join(file_path))?
.write_all(b"test file1 content")?;

stage_add_file(repo_path, file_path)?;
Expand All @@ -190,7 +190,7 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?
File::create(root.join(file_path))?
.write_all(b"test file1 content")?;

let id = stash_save(repo_path, None, true, false)?;
Expand All @@ -212,13 +212,13 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path1))?.write_all(b"test")?;
File::create(root.join(file_path1))?.write_all(b"test")?;
stage_add_file(repo_path, file_path1)?;
commit(repo_path, "c1")?;

File::create(&root.join(file_path1))?
File::create(root.join(file_path1))?
.write_all(b"modified")?;
File::create(&root.join(file_path2))?.write_all(b"new")?;
File::create(root.join(file_path2))?.write_all(b"new")?;

assert_eq!(get_statuses(repo_path), (2, 0));

Expand Down
8 changes: 4 additions & 4 deletions asyncgit/src/sync/commits_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?.write_all(b"a")?;
File::create(root.join(file_path))?.write_all(b"a")?;
stage_add_file(repo_path, file_path).unwrap();
let c1 = commit(repo_path, "commit1").unwrap();
File::create(&root.join(file_path))?.write_all(b"a")?;
File::create(root.join(file_path))?.write_all(b"a")?;
stage_add_file(repo_path, file_path).unwrap();
let c2 = commit(repo_path, "commit2").unwrap();

Expand All @@ -182,7 +182,7 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?.write_all(b"a")?;
File::create(root.join(file_path))?.write_all(b"a")?;
stage_add_file(repo_path, file_path).unwrap();
let c1 = commit(repo_path, "subject\nbody").unwrap();

Expand All @@ -202,7 +202,7 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?.write_all(b"a")?;
File::create(root.join(file_path))?.write_all(b"a")?;
stage_add_file(repo_path, file_path).unwrap();

let msg = invalidstring::invalid_utf8("test msg");
Expand Down
21 changes: 9 additions & 12 deletions asyncgit/src/sync/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,8 @@ mod tests {

assert_eq!(get_statuses(repo_path), (0, 0));

fs::create_dir(&root.join("foo")).unwrap();
File::create(&root.join("foo/bar.txt"))
fs::create_dir(root.join("foo")).unwrap();
File::create(root.join("foo/bar.txt"))
.unwrap()
.write_all(b"test\nfoo")
.unwrap();
Expand All @@ -464,7 +464,7 @@ mod tests {

assert_eq!(get_statuses(repo_path), (0, 0));

File::create(&root.join(file_path))
File::create(root.join(file_path))
.unwrap()
.write_all(b"test\nfoo")
.unwrap();
Expand Down Expand Up @@ -563,7 +563,7 @@ mod tests {
let sub_path = root.join("foo/");

fs::create_dir_all(&sub_path).unwrap();
File::create(&root.join(file_path))
File::create(root.join(file_path))
.unwrap()
.write_all(b"test")
.unwrap();
Expand All @@ -587,14 +587,13 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?.write_all(b"\x00")?;
File::create(root.join(file_path))?.write_all(b"\x00")?;

stage_add_file(repo_path, file_path).unwrap();

commit(repo_path, "commit").unwrap();

File::create(&root.join(file_path))?
.write_all(b"\x00\x02")?;
File::create(root.join(file_path))?.write_all(b"\x00\x02")?;

let diff = get_diff(
repo_path,
Expand All @@ -619,8 +618,7 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?
.write_all(b"\x00\xc7")?;
File::create(root.join(file_path))?.write_all(b"\x00\xc7")?;

let diff = get_diff(
repo_path,
Expand All @@ -645,14 +643,13 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?.write_all(b"\x00")?;
File::create(root.join(file_path))?.write_all(b"\x00")?;

stage_add_file(repo_path, file_path).unwrap();

commit(repo_path, "").unwrap();

File::create(&root.join(file_path))?
.write_all(b"\x00\x02")?;
File::create(root.join(file_path))?.write_all(b"\x00\x02")?;

stage_add_file(repo_path, file_path).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion asyncgit/src/sync/hunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ mod tests {
let sub_path = root.join("foo/");

fs::create_dir_all(&sub_path)?;
File::create(&root.join(file_path))?.write_all(b"test")?;
File::create(root.join(file_path))?.write_all(b"test")?;

let sub_path: &RepoPath = &sub_path.to_str().unwrap().into();
let diff = get_diff(
Expand Down
16 changes: 8 additions & 8 deletions asyncgit/src/sync/ignore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?.write_all(b"test")?;
File::create(root.join(file_path))?.write_all(b"test")?;

assert_eq!(root.join(ignore_file_path).exists(), false);
add_to_ignore(repo_path, file_path.to_str().unwrap())?;
Expand Down Expand Up @@ -105,14 +105,14 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?.write_all(b"test")?;
File::create(&root.join(ignore_file_path))?
File::create(root.join(file_path))?.write_all(b"test")?;
File::create(root.join(ignore_file_path))?
.write_all(b"foo\n")?;

add_to_ignore(repo_path, file_path.to_str().unwrap())?;

let mut lines =
read_lines(&root.join(ignore_file_path)).unwrap();
read_lines(root.join(ignore_file_path)).unwrap();
assert_eq!(&lines.nth(1).unwrap().unwrap(), "foo.txt");

Ok(())
Expand All @@ -127,14 +127,14 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?.write_all(b"test")?;
File::create(&root.join(ignore_file_path))?
File::create(root.join(file_path))?.write_all(b"test")?;
File::create(root.join(ignore_file_path))?
.write_all(b"foo")?;

add_to_ignore(repo_path, file_path.to_str().unwrap())?;

let mut lines =
read_lines(&root.join(ignore_file_path)).unwrap();
read_lines(root.join(ignore_file_path)).unwrap();
assert_eq!(&lines.nth(1).unwrap().unwrap(), "foo.txt");

Ok(())
Expand All @@ -153,7 +153,7 @@ mod tests {
let res = add_to_ignore(repo_path, ".gitignore");
assert!(res.is_err());

let lines = read_lines(&root.join(ignore_file_path)).unwrap();
let lines = read_lines(root.join(ignore_file_path)).unwrap();
assert_eq!(lines.count(), 1);
}
}
15 changes: 7 additions & 8 deletions asyncgit/src/sync/logwalker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?.write_all(b"a")?;
File::create(root.join(file_path))?.write_all(b"a")?;
stage_add_file(repo_path, file_path).unwrap();
commit(repo_path, "commit1").unwrap();
File::create(&root.join(file_path))?.write_all(b"a")?;
File::create(root.join(file_path))?.write_all(b"a")?;
stage_add_file(repo_path, file_path).unwrap();
let oid2 = commit(repo_path, "commit2").unwrap();

Expand All @@ -175,10 +175,10 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?.write_all(b"a")?;
File::create(root.join(file_path))?.write_all(b"a")?;
stage_add_file(repo_path, file_path).unwrap();
commit(repo_path, "commit1").unwrap();
File::create(&root.join(file_path))?.write_all(b"a")?;
File::create(root.join(file_path))?.write_all(b"a")?;
stage_add_file(repo_path, file_path).unwrap();
let oid2 = commit(repo_path, "commit2").unwrap();

Expand Down Expand Up @@ -209,18 +209,17 @@ mod tests {
let repo_path: RepoPath =
root.as_os_str().to_str().unwrap().into();

File::create(&root.join(file_path))?.write_all(b"a")?;
File::create(root.join(file_path))?.write_all(b"a")?;
stage_add_file(&repo_path, file_path).unwrap();

let _first_commit_id = commit(&repo_path, "commit1").unwrap();

File::create(&root.join(second_file_path))?
.write_all(b"a")?;
File::create(root.join(second_file_path))?.write_all(b"a")?;
stage_add_file(&repo_path, second_file_path).unwrap();

let second_commit_id = commit(&repo_path, "commit2").unwrap();

File::create(&root.join(file_path))?.write_all(b"b")?;
File::create(root.join(file_path))?.write_all(b"b")?;
stage_add_file(&repo_path, file_path).unwrap();

let _third_commit_id = commit(&repo_path, "commit3").unwrap();
Expand Down
3 changes: 1 addition & 2 deletions asyncgit/src/sync/remotes/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ pub fn push_raw(
callbacks.get_stats()?.push_rejected_msg
{
return Err(Error::Generic(format!(
"push to '{}' rejected: {}",
reference, msg
"push to '{reference}' rejected: {msg}"
)));
}

Expand Down
Loading

0 comments on commit 289eddd

Please sign in to comment.