mirror of
https://github.com/extrawurst/gitui.git
synced 2024-12-28 03:22:51 +03:00
fix nightly clippy
This commit is contained in:
parent
7dcf93e0b2
commit
289eddd9be
@ -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")?;
|
||||
@ -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")?;
|
||||
|
||||
@ -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();
|
||||
|
@ -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();
|
||||
@ -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();
|
||||
@ -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)?;
|
||||
|
||||
@ -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)?;
|
||||
@ -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)?;
|
||||
@ -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)?;
|
||||
@ -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)?;
|
||||
|
@ -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");
|
||||
|
@ -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)?;
|
||||
@ -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)?;
|
||||
@ -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));
|
||||
|
||||
|
@ -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();
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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");
|
||||
|
@ -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();
|
||||
@ -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();
|
||||
@ -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();
|
||||
@ -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,
|
||||
@ -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,
|
||||
@ -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();
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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())?;
|
||||
@ -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(())
|
||||
@ -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(())
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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();
|
||||
|
@ -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}"
|
||||
)));
|
||||
}
|
||||
|
||||
|
@ -136,8 +136,8 @@ mod tests {
|
||||
&root.as_os_str().to_str().unwrap().into();
|
||||
|
||||
{
|
||||
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();
|
||||
@ -162,12 +162,12 @@ mod tests {
|
||||
&root.as_os_str().to_str().unwrap().into();
|
||||
|
||||
{
|
||||
fs::create_dir(&root.join("foo"))?;
|
||||
File::create(&root.join("foo/file1.txt"))?
|
||||
fs::create_dir(root.join("foo"))?;
|
||||
File::create(root.join("foo/file1.txt"))?
|
||||
.write_all(b"file1")?;
|
||||
File::create(&root.join("foo/file2.txt"))?
|
||||
File::create(root.join("foo/file2.txt"))?
|
||||
.write_all(b"file1")?;
|
||||
File::create(&root.join("file3.txt"))?
|
||||
File::create(root.join("file3.txt"))?
|
||||
.write_all(b"file3")?;
|
||||
}
|
||||
|
||||
@ -175,14 +175,14 @@ mod tests {
|
||||
commit(repo_path, "msg").unwrap();
|
||||
|
||||
{
|
||||
File::create(&root.join("foo/file1.txt"))?
|
||||
File::create(root.join("foo/file1.txt"))?
|
||||
.write_all(b"file1\nadded line")?;
|
||||
fs::remove_file(&root.join("foo/file2.txt"))?;
|
||||
File::create(&root.join("foo/file4.txt"))?
|
||||
fs::remove_file(root.join("foo/file2.txt"))?;
|
||||
File::create(root.join("foo/file4.txt"))?
|
||||
.write_all(b"file4")?;
|
||||
File::create(&root.join("foo/file5.txt"))?
|
||||
File::create(root.join("foo/file5.txt"))?
|
||||
.write_all(b"file5")?;
|
||||
File::create(&root.join("file3.txt"))?
|
||||
File::create(root.join("file3.txt"))?
|
||||
.write_all(b"file3\nadded line")?;
|
||||
}
|
||||
|
||||
@ -209,8 +209,8 @@ mod tests {
|
||||
let file = "foo/bar.txt";
|
||||
|
||||
{
|
||||
fs::create_dir(&root.join("foo")).unwrap();
|
||||
File::create(&root.join(file))
|
||||
fs::create_dir(root.join("foo")).unwrap();
|
||||
File::create(root.join(file))
|
||||
.unwrap()
|
||||
.write_all(b"test\nfoo")
|
||||
.unwrap();
|
||||
@ -223,7 +223,7 @@ mod tests {
|
||||
debug_cmd_print(repo_path, "git status");
|
||||
|
||||
{
|
||||
File::create(&root.join(file))
|
||||
File::create(root.join(file))
|
||||
.unwrap()
|
||||
.write_all(b"test\nfoo\nnewend")
|
||||
.unwrap();
|
||||
@ -248,7 +248,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();
|
||||
@ -272,8 +272,8 @@ mod tests {
|
||||
&root.as_os_str().to_str().unwrap().into();
|
||||
|
||||
{
|
||||
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();
|
||||
@ -302,8 +302,8 @@ mod tests {
|
||||
&root.as_os_str().to_str().unwrap().into();
|
||||
|
||||
{
|
||||
fs::create_dir_all(&root.join("foo/bar")).unwrap();
|
||||
File::create(&root.join("foo/bar/baz.txt"))
|
||||
fs::create_dir_all(root.join("foo/bar")).unwrap();
|
||||
File::create(root.join("foo/bar/baz.txt"))
|
||||
.unwrap()
|
||||
.write_all(b"test\nfoo")
|
||||
.unwrap();
|
||||
|
@ -170,7 +170,7 @@ mod tests {
|
||||
let repo_path: &RepoPath =
|
||||
&root.as_os_str().to_str().unwrap().into();
|
||||
|
||||
File::create(&root.join("foo.txt"))?
|
||||
File::create(root.join("foo.txt"))?
|
||||
.write_all(b"test\nfoo")?;
|
||||
|
||||
assert_eq!(get_statuses(repo_path), (1, 0));
|
||||
@ -189,7 +189,7 @@ mod tests {
|
||||
let repo_path: &RepoPath =
|
||||
&root.as_os_str().to_str().unwrap().into();
|
||||
|
||||
File::create(&root.join("foo.txt"))?
|
||||
File::create(root.join("foo.txt"))?
|
||||
.write_all(b"test\nfoo")?;
|
||||
|
||||
stash_save(repo_path, Some("foo"), true, false)?;
|
||||
@ -213,7 +213,7 @@ mod tests {
|
||||
let repo_path: &RepoPath =
|
||||
&root.as_os_str().to_str().unwrap().into();
|
||||
|
||||
File::create(&root.join("foo.txt"))?
|
||||
File::create(root.join("foo.txt"))?
|
||||
.write_all(b"test\nfoo")?;
|
||||
|
||||
assert!(
|
||||
@ -231,11 +231,11 @@ 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")?;
|
||||
|
||||
//NOTE: apparently `libgit2` works differently to git stash in
|
||||
|
@ -256,12 +256,12 @@ 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 file1 content")
|
||||
.unwrap();
|
||||
|
||||
File::create(&root.join(Path::new("file2.txt")))
|
||||
File::create(root.join(Path::new("file2.txt")))
|
||||
.unwrap()
|
||||
.write_all(b"test file2 content")
|
||||
.unwrap();
|
||||
@ -284,12 +284,12 @@ mod tests {
|
||||
get_status(repo_path, s, None).unwrap().len()
|
||||
};
|
||||
|
||||
fs::create_dir_all(&root.join("a/d"))?;
|
||||
File::create(&root.join(Path::new("a/d/f1.txt")))?
|
||||
fs::create_dir_all(root.join("a/d"))?;
|
||||
File::create(root.join(Path::new("a/d/f1.txt")))?
|
||||
.write_all(b"foo")?;
|
||||
File::create(&root.join(Path::new("a/d/f2.txt")))?
|
||||
File::create(root.join(Path::new("a/d/f2.txt")))?
|
||||
.write_all(b"foo")?;
|
||||
File::create(&root.join(Path::new("a/f3.txt")))?
|
||||
File::create(root.join(Path::new("a/f3.txt")))?
|
||||
.write_all(b"foo")?;
|
||||
|
||||
assert_eq!(status_count(StatusType::WorkingDir), 3);
|
||||
@ -346,12 +346,12 @@ mod tests {
|
||||
let repo_path: &RepoPath =
|
||||
&root.as_os_str().to_str().unwrap().into();
|
||||
|
||||
fs::create_dir_all(&root.join("a/d"))?;
|
||||
File::create(&root.join(Path::new("a/d/f1.txt")))?
|
||||
fs::create_dir_all(root.join("a/d"))?;
|
||||
File::create(root.join(Path::new("a/d/f1.txt")))?
|
||||
.write_all(b"foo")?;
|
||||
File::create(&root.join(Path::new("a/d/f2.txt")))?
|
||||
File::create(root.join(Path::new("a/d/f2.txt")))?
|
||||
.write_all(b"foo")?;
|
||||
File::create(&root.join(Path::new("f3.txt")))?
|
||||
File::create(root.join(Path::new("f3.txt")))?
|
||||
.write_all(b"foo")?;
|
||||
|
||||
assert_eq!(get_statuses(repo_path), (3, 0));
|
||||
|
@ -985,8 +985,7 @@ impl App {
|
||||
branch_ref.rsplit('/').next().map_or_else(
|
||||
|| {
|
||||
InternalEvent::ShowErrorMsg(format!(
|
||||
"Failed to find the branch name in {}",
|
||||
branch_ref
|
||||
"Failed to find the branch name in {branch_ref}"
|
||||
))
|
||||
},
|
||||
|name| {
|
||||
|
@ -454,10 +454,7 @@ impl BlameFileComponent {
|
||||
let line_number_width = self.get_line_number_width();
|
||||
cells.push(
|
||||
Cell::from(format!(
|
||||
"{:>line_number_width$}{}",
|
||||
line_number,
|
||||
VERTICAL,
|
||||
line_number_width = line_number_width,
|
||||
"{line_number:>line_number_width$}{VERTICAL}",
|
||||
))
|
||||
.style(self.theme.text(true, false)),
|
||||
);
|
||||
@ -483,11 +480,7 @@ impl BlameFileComponent {
|
||||
|| NO_AUTHOR.into(),
|
||||
|hunk| string_width_align(&hunk.author, author_width),
|
||||
);
|
||||
let author = format!(
|
||||
"{:author_width$}",
|
||||
truncated_author,
|
||||
author_width = MAX_AUTHOR_WIDTH
|
||||
);
|
||||
let author = format!("{truncated_author:MAX_AUTHOR_WIDTH$}");
|
||||
let time = blame_hunk.map_or_else(String::new, |hunk| {
|
||||
utils::time_to_string(hunk.time, true)
|
||||
});
|
||||
|
@ -624,11 +624,7 @@ impl BranchListComponent {
|
||||
theme.text(true, selected),
|
||||
);
|
||||
let span_name = Span::styled(
|
||||
format!(
|
||||
"{:w$} ",
|
||||
branch_name,
|
||||
w = branch_name_length
|
||||
),
|
||||
format!("{branch_name:branch_name_length$} "),
|
||||
theme.branch(selected, is_head),
|
||||
);
|
||||
|
||||
|
@ -241,8 +241,7 @@ impl CommitComponent {
|
||||
{
|
||||
log::error!("pre-commit hook error: {}", e);
|
||||
self.queue.push(InternalEvent::ShowErrorMsg(format!(
|
||||
"pre-commit hook error:\n{}",
|
||||
e
|
||||
"pre-commit hook error:\n{e}"
|
||||
)));
|
||||
return Ok(CommitResult::Aborted);
|
||||
}
|
||||
@ -252,8 +251,7 @@ impl CommitComponent {
|
||||
{
|
||||
log::error!("commit-msg hook error: {}", e);
|
||||
self.queue.push(InternalEvent::ShowErrorMsg(format!(
|
||||
"commit-msg hook error:\n{}",
|
||||
e
|
||||
"commit-msg hook error:\n{e}"
|
||||
)));
|
||||
return Ok(CommitResult::Aborted);
|
||||
}
|
||||
@ -276,8 +274,7 @@ impl CommitComponent {
|
||||
{
|
||||
log::error!("post-commit hook error: {}", e);
|
||||
self.queue.push(InternalEvent::ShowErrorMsg(format!(
|
||||
"post-commit hook error:\n{}",
|
||||
e
|
||||
"post-commit hook error:\n{e}"
|
||||
)));
|
||||
}
|
||||
|
||||
|
@ -326,8 +326,7 @@ impl DiffComponent {
|
||||
Span::raw(Cow::from(" (")),
|
||||
Span::styled(
|
||||
Cow::from(format!(
|
||||
"{}{:}",
|
||||
sign, delta_byte_size
|
||||
"{sign}{delta_byte_size:}"
|
||||
)),
|
||||
self.theme.diff_line(
|
||||
if is_positive {
|
||||
|
@ -199,11 +199,7 @@ impl RevisionFilesComponent {
|
||||
width.saturating_sub(indent_str.len() + path_arrow.len());
|
||||
|
||||
let path = format!(
|
||||
"{}{}{:w$}",
|
||||
indent_str,
|
||||
path_arrow,
|
||||
path,
|
||||
w = available_width
|
||||
"{indent_str}{path_arrow}{path:available_width$}"
|
||||
);
|
||||
|
||||
Span::styled(path, theme.file_tree_item(is_path, selected))
|
||||
|
@ -215,10 +215,7 @@ impl StatusTreeComponent {
|
||||
w = width as usize
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
" {}{}{}",
|
||||
indent_str, collapse_char, string,
|
||||
)
|
||||
format!(" {indent_str}{collapse_char}{string}",)
|
||||
};
|
||||
|
||||
Some(Span::styled(
|
||||
|
@ -132,8 +132,7 @@ impl SyntaxTextComponent {
|
||||
self.current_file = Some((
|
||||
path,
|
||||
Either::Right(format!(
|
||||
"error loading file: {}",
|
||||
e
|
||||
"error loading file: {e}"
|
||||
)),
|
||||
));
|
||||
}
|
||||
|
@ -193,8 +193,7 @@ pub fn confirm_msg_reset() -> String {
|
||||
}
|
||||
pub fn confirm_msg_reset_lines(lines: usize) -> String {
|
||||
format!(
|
||||
"are you sure you want to discard {} selected lines?",
|
||||
lines
|
||||
"are you sure you want to discard {lines} selected lines?"
|
||||
)
|
||||
}
|
||||
pub fn confirm_msg_stashdrop(
|
||||
@ -273,8 +272,7 @@ pub fn confirm_msg_force_push(
|
||||
branch_ref: &str,
|
||||
) -> String {
|
||||
format!(
|
||||
"Confirm force push to branch '{}' ? This may rewrite history.",
|
||||
branch_ref
|
||||
"Confirm force push to branch '{branch_ref}' ? This may rewrite history."
|
||||
)
|
||||
}
|
||||
pub fn log_title(_key_config: &SharedKeyConfig) -> String {
|
||||
@ -285,10 +283,7 @@ pub fn file_log_title(
|
||||
selected: usize,
|
||||
revisions: usize,
|
||||
) -> String {
|
||||
format!(
|
||||
"Revisions of '{}' ({}/{})",
|
||||
file_path, selected, revisions
|
||||
)
|
||||
format!("Revisions of '{file_path}' ({selected}/{revisions})")
|
||||
}
|
||||
pub fn blame_title(_key_config: &SharedKeyConfig) -> String {
|
||||
"Blame".to_string()
|
||||
|
@ -232,8 +232,7 @@ impl Status {
|
||||
});
|
||||
|
||||
let w = Paragraph::new(format!(
|
||||
"{}{{{}}}",
|
||||
ahead_behind, branch_name
|
||||
"{ahead_behind}{{{branch_name}}}"
|
||||
))
|
||||
.alignment(Alignment::Right);
|
||||
|
||||
@ -560,8 +559,7 @@ impl Status {
|
||||
item.path.as_str(),
|
||||
) {
|
||||
self.queue.push(InternalEvent::ShowErrorMsg(format!(
|
||||
"reset failed:\n{}",
|
||||
e
|
||||
"reset failed:\n{e}"
|
||||
)));
|
||||
|
||||
false
|
||||
|
Loading…
Reference in New Issue
Block a user