mirror of
https://github.com/extrawurst/gitui.git
synced 2024-12-29 12:06:26 +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(_)));
|
assert!(matches!(blame_file(repo_path, "foo", None), Err(_)));
|
||||||
|
|
||||||
File::create(&root.join(file_path))?
|
File::create(root.join(file_path))?.write_all(b"line 1\n")?;
|
||||||
.write_all(b"line 1\n")?;
|
|
||||||
|
|
||||||
stage_add_file(repo_path, file_path)?;
|
stage_add_file(repo_path, file_path)?;
|
||||||
commit(repo_path, "first commit")?;
|
commit(repo_path, "first commit")?;
|
||||||
@ -195,7 +194,7 @@ mod tests {
|
|||||||
|
|
||||||
let mut file = OpenOptions::new()
|
let mut file = OpenOptions::new()
|
||||||
.append(true)
|
.append(true)
|
||||||
.open(&root.join(file_path))?;
|
.open(root.join(file_path))?;
|
||||||
|
|
||||||
file.write(b"line 2\n")?;
|
file.write(b"line 2\n")?;
|
||||||
|
|
||||||
@ -251,9 +250,9 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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()
|
.unwrap()
|
||||||
.write_all(b"line 1\n")
|
.write_all(b"line 1\n")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -151,7 +151,7 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&root.as_os_str().to_str().unwrap().into();
|
||||||
|
|
||||||
File::create(&root.join(file_path))
|
File::create(root.join(file_path))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.write_all(b"test\nfoo")
|
.write_all(b"test\nfoo")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -177,7 +177,7 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(get_statuses(repo_path), (0, 0));
|
assert_eq!(get_statuses(repo_path), (0, 0));
|
||||||
|
|
||||||
File::create(&root.join(file_path))
|
File::create(root.join(file_path))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.write_all(b"test\nfoo")
|
.write_all(b"test\nfoo")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -202,14 +202,14 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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)?;
|
stage_add_file(repo_path, file_path1)?;
|
||||||
let id = commit(repo_path, "commit msg")?;
|
let id = commit(repo_path, "commit msg")?;
|
||||||
|
|
||||||
assert_eq!(count_commits(&repo, 10), 1);
|
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)?;
|
stage_add_file(repo_path, file_path2)?;
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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")?;
|
.write_all(b"test\nfoo")?;
|
||||||
|
|
||||||
stage_add_file(repo_path, file_path)?;
|
stage_add_file(repo_path, file_path)?;
|
||||||
@ -281,7 +281,7 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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")?;
|
.write_all(b"test\nfoo")?;
|
||||||
|
|
||||||
stage_add_file(repo_path, file_path)?;
|
stage_add_file(repo_path, file_path)?;
|
||||||
@ -315,7 +315,7 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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")?;
|
.write_all(b"test\nfoo")?;
|
||||||
|
|
||||||
stage_add_file(repo_path, file_path)?;
|
stage_add_file(repo_path, file_path)?;
|
||||||
@ -351,7 +351,7 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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")?;
|
.write_all(b"test\nfoo")?;
|
||||||
|
|
||||||
stage_add_file(repo_path, file_path)?;
|
stage_add_file(repo_path, file_path)?;
|
||||||
|
@ -140,7 +140,7 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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();
|
stage_add_file(repo_path, file_path).unwrap();
|
||||||
|
|
||||||
let msg = invalidstring::invalid_utf8("test msg");
|
let msg = invalidstring::invalid_utf8("test msg");
|
||||||
|
@ -167,7 +167,7 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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")?;
|
.write_all(b"test file1 content")?;
|
||||||
|
|
||||||
stage_add_file(repo_path, file_path)?;
|
stage_add_file(repo_path, file_path)?;
|
||||||
@ -190,7 +190,7 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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")?;
|
.write_all(b"test file1 content")?;
|
||||||
|
|
||||||
let id = stash_save(repo_path, None, true, false)?;
|
let id = stash_save(repo_path, None, true, false)?;
|
||||||
@ -212,13 +212,13 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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)?;
|
stage_add_file(repo_path, file_path1)?;
|
||||||
commit(repo_path, "c1")?;
|
commit(repo_path, "c1")?;
|
||||||
|
|
||||||
File::create(&root.join(file_path1))?
|
File::create(root.join(file_path1))?
|
||||||
.write_all(b"modified")?;
|
.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));
|
assert_eq!(get_statuses(repo_path), (2, 0));
|
||||||
|
|
||||||
|
@ -157,10 +157,10 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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();
|
stage_add_file(repo_path, file_path).unwrap();
|
||||||
let c1 = commit(repo_path, "commit1").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();
|
stage_add_file(repo_path, file_path).unwrap();
|
||||||
let c2 = commit(repo_path, "commit2").unwrap();
|
let c2 = commit(repo_path, "commit2").unwrap();
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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();
|
stage_add_file(repo_path, file_path).unwrap();
|
||||||
let c1 = commit(repo_path, "subject\nbody").unwrap();
|
let c1 = commit(repo_path, "subject\nbody").unwrap();
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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();
|
stage_add_file(repo_path, file_path).unwrap();
|
||||||
|
|
||||||
let msg = invalidstring::invalid_utf8("test msg");
|
let msg = invalidstring::invalid_utf8("test msg");
|
||||||
|
@ -439,8 +439,8 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(get_statuses(repo_path), (0, 0));
|
assert_eq!(get_statuses(repo_path), (0, 0));
|
||||||
|
|
||||||
fs::create_dir(&root.join("foo")).unwrap();
|
fs::create_dir(root.join("foo")).unwrap();
|
||||||
File::create(&root.join("foo/bar.txt"))
|
File::create(root.join("foo/bar.txt"))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.write_all(b"test\nfoo")
|
.write_all(b"test\nfoo")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -464,7 +464,7 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(get_statuses(repo_path), (0, 0));
|
assert_eq!(get_statuses(repo_path), (0, 0));
|
||||||
|
|
||||||
File::create(&root.join(file_path))
|
File::create(root.join(file_path))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.write_all(b"test\nfoo")
|
.write_all(b"test\nfoo")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -563,7 +563,7 @@ mod tests {
|
|||||||
let sub_path = root.join("foo/");
|
let sub_path = root.join("foo/");
|
||||||
|
|
||||||
fs::create_dir_all(&sub_path).unwrap();
|
fs::create_dir_all(&sub_path).unwrap();
|
||||||
File::create(&root.join(file_path))
|
File::create(root.join(file_path))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.write_all(b"test")
|
.write_all(b"test")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -587,14 +587,13 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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();
|
stage_add_file(repo_path, file_path).unwrap();
|
||||||
|
|
||||||
commit(repo_path, "commit").unwrap();
|
commit(repo_path, "commit").unwrap();
|
||||||
|
|
||||||
File::create(&root.join(file_path))?
|
File::create(root.join(file_path))?.write_all(b"\x00\x02")?;
|
||||||
.write_all(b"\x00\x02")?;
|
|
||||||
|
|
||||||
let diff = get_diff(
|
let diff = get_diff(
|
||||||
repo_path,
|
repo_path,
|
||||||
@ -619,8 +618,7 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&root.as_os_str().to_str().unwrap().into();
|
||||||
|
|
||||||
File::create(&root.join(file_path))?
|
File::create(root.join(file_path))?.write_all(b"\x00\xc7")?;
|
||||||
.write_all(b"\x00\xc7")?;
|
|
||||||
|
|
||||||
let diff = get_diff(
|
let diff = get_diff(
|
||||||
repo_path,
|
repo_path,
|
||||||
@ -645,14 +643,13 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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();
|
stage_add_file(repo_path, file_path).unwrap();
|
||||||
|
|
||||||
commit(repo_path, "").unwrap();
|
commit(repo_path, "").unwrap();
|
||||||
|
|
||||||
File::create(&root.join(file_path))?
|
File::create(root.join(file_path))?.write_all(b"\x00\x02")?;
|
||||||
.write_all(b"\x00\x02")?;
|
|
||||||
|
|
||||||
stage_add_file(repo_path, file_path).unwrap();
|
stage_add_file(repo_path, file_path).unwrap();
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ mod tests {
|
|||||||
let sub_path = root.join("foo/");
|
let sub_path = root.join("foo/");
|
||||||
|
|
||||||
fs::create_dir_all(&sub_path)?;
|
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 sub_path: &RepoPath = &sub_path.to_str().unwrap().into();
|
||||||
let diff = get_diff(
|
let diff = get_diff(
|
||||||
|
@ -77,7 +77,7 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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);
|
assert_eq!(root.join(ignore_file_path).exists(), false);
|
||||||
add_to_ignore(repo_path, file_path.to_str().unwrap())?;
|
add_to_ignore(repo_path, file_path.to_str().unwrap())?;
|
||||||
@ -105,14 +105,14 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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")?;
|
||||||
File::create(&root.join(ignore_file_path))?
|
File::create(root.join(ignore_file_path))?
|
||||||
.write_all(b"foo\n")?;
|
.write_all(b"foo\n")?;
|
||||||
|
|
||||||
add_to_ignore(repo_path, file_path.to_str().unwrap())?;
|
add_to_ignore(repo_path, file_path.to_str().unwrap())?;
|
||||||
|
|
||||||
let mut lines =
|
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");
|
assert_eq!(&lines.nth(1).unwrap().unwrap(), "foo.txt");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -127,14 +127,14 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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")?;
|
||||||
File::create(&root.join(ignore_file_path))?
|
File::create(root.join(ignore_file_path))?
|
||||||
.write_all(b"foo")?;
|
.write_all(b"foo")?;
|
||||||
|
|
||||||
add_to_ignore(repo_path, file_path.to_str().unwrap())?;
|
add_to_ignore(repo_path, file_path.to_str().unwrap())?;
|
||||||
|
|
||||||
let mut lines =
|
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");
|
assert_eq!(&lines.nth(1).unwrap().unwrap(), "foo.txt");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -153,7 +153,7 @@ mod tests {
|
|||||||
let res = add_to_ignore(repo_path, ".gitignore");
|
let res = add_to_ignore(repo_path, ".gitignore");
|
||||||
assert!(res.is_err());
|
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);
|
assert_eq!(lines.count(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,10 +150,10 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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();
|
stage_add_file(repo_path, file_path).unwrap();
|
||||||
commit(repo_path, "commit1").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();
|
stage_add_file(repo_path, file_path).unwrap();
|
||||||
let oid2 = commit(repo_path, "commit2").unwrap();
|
let oid2 = commit(repo_path, "commit2").unwrap();
|
||||||
|
|
||||||
@ -175,10 +175,10 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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();
|
stage_add_file(repo_path, file_path).unwrap();
|
||||||
commit(repo_path, "commit1").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();
|
stage_add_file(repo_path, file_path).unwrap();
|
||||||
let oid2 = commit(repo_path, "commit2").unwrap();
|
let oid2 = commit(repo_path, "commit2").unwrap();
|
||||||
|
|
||||||
@ -209,18 +209,17 @@ mod tests {
|
|||||||
let repo_path: RepoPath =
|
let repo_path: RepoPath =
|
||||||
root.as_os_str().to_str().unwrap().into();
|
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();
|
stage_add_file(&repo_path, file_path).unwrap();
|
||||||
|
|
||||||
let _first_commit_id = commit(&repo_path, "commit1").unwrap();
|
let _first_commit_id = commit(&repo_path, "commit1").unwrap();
|
||||||
|
|
||||||
File::create(&root.join(second_file_path))?
|
File::create(root.join(second_file_path))?.write_all(b"a")?;
|
||||||
.write_all(b"a")?;
|
|
||||||
stage_add_file(&repo_path, second_file_path).unwrap();
|
stage_add_file(&repo_path, second_file_path).unwrap();
|
||||||
|
|
||||||
let second_commit_id = commit(&repo_path, "commit2").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();
|
stage_add_file(&repo_path, file_path).unwrap();
|
||||||
|
|
||||||
let _third_commit_id = commit(&repo_path, "commit3").unwrap();
|
let _third_commit_id = commit(&repo_path, "commit3").unwrap();
|
||||||
|
@ -171,8 +171,7 @@ pub fn push_raw(
|
|||||||
callbacks.get_stats()?.push_rejected_msg
|
callbacks.get_stats()?.push_rejected_msg
|
||||||
{
|
{
|
||||||
return Err(Error::Generic(format!(
|
return Err(Error::Generic(format!(
|
||||||
"push to '{}' rejected: {}",
|
"push to '{reference}' rejected: {msg}"
|
||||||
reference, msg
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,8 +136,8 @@ mod tests {
|
|||||||
&root.as_os_str().to_str().unwrap().into();
|
&root.as_os_str().to_str().unwrap().into();
|
||||||
|
|
||||||
{
|
{
|
||||||
fs::create_dir(&root.join("foo")).unwrap();
|
fs::create_dir(root.join("foo")).unwrap();
|
||||||
File::create(&root.join("foo/bar.txt"))
|
File::create(root.join("foo/bar.txt"))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.write_all(b"test\nfoo")
|
.write_all(b"test\nfoo")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -162,12 +162,12 @@ mod tests {
|
|||||||
&root.as_os_str().to_str().unwrap().into();
|
&root.as_os_str().to_str().unwrap().into();
|
||||||
|
|
||||||
{
|
{
|
||||||
fs::create_dir(&root.join("foo"))?;
|
fs::create_dir(root.join("foo"))?;
|
||||||
File::create(&root.join("foo/file1.txt"))?
|
File::create(root.join("foo/file1.txt"))?
|
||||||
.write_all(b"file1")?;
|
.write_all(b"file1")?;
|
||||||
File::create(&root.join("foo/file2.txt"))?
|
File::create(root.join("foo/file2.txt"))?
|
||||||
.write_all(b"file1")?;
|
.write_all(b"file1")?;
|
||||||
File::create(&root.join("file3.txt"))?
|
File::create(root.join("file3.txt"))?
|
||||||
.write_all(b"file3")?;
|
.write_all(b"file3")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,14 +175,14 @@ mod tests {
|
|||||||
commit(repo_path, "msg").unwrap();
|
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")?;
|
.write_all(b"file1\nadded line")?;
|
||||||
fs::remove_file(&root.join("foo/file2.txt"))?;
|
fs::remove_file(root.join("foo/file2.txt"))?;
|
||||||
File::create(&root.join("foo/file4.txt"))?
|
File::create(root.join("foo/file4.txt"))?
|
||||||
.write_all(b"file4")?;
|
.write_all(b"file4")?;
|
||||||
File::create(&root.join("foo/file5.txt"))?
|
File::create(root.join("foo/file5.txt"))?
|
||||||
.write_all(b"file5")?;
|
.write_all(b"file5")?;
|
||||||
File::create(&root.join("file3.txt"))?
|
File::create(root.join("file3.txt"))?
|
||||||
.write_all(b"file3\nadded line")?;
|
.write_all(b"file3\nadded line")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,8 +209,8 @@ mod tests {
|
|||||||
let file = "foo/bar.txt";
|
let file = "foo/bar.txt";
|
||||||
|
|
||||||
{
|
{
|
||||||
fs::create_dir(&root.join("foo")).unwrap();
|
fs::create_dir(root.join("foo")).unwrap();
|
||||||
File::create(&root.join(file))
|
File::create(root.join(file))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.write_all(b"test\nfoo")
|
.write_all(b"test\nfoo")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -223,7 +223,7 @@ mod tests {
|
|||||||
debug_cmd_print(repo_path, "git status");
|
debug_cmd_print(repo_path, "git status");
|
||||||
|
|
||||||
{
|
{
|
||||||
File::create(&root.join(file))
|
File::create(root.join(file))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.write_all(b"test\nfoo\nnewend")
|
.write_all(b"test\nfoo\nnewend")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -248,7 +248,7 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&root.as_os_str().to_str().unwrap().into();
|
||||||
|
|
||||||
File::create(&root.join(file_path))
|
File::create(root.join(file_path))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.write_all(b"test\nfoo")
|
.write_all(b"test\nfoo")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -272,8 +272,8 @@ mod tests {
|
|||||||
&root.as_os_str().to_str().unwrap().into();
|
&root.as_os_str().to_str().unwrap().into();
|
||||||
|
|
||||||
{
|
{
|
||||||
fs::create_dir(&root.join("foo")).unwrap();
|
fs::create_dir(root.join("foo")).unwrap();
|
||||||
File::create(&root.join("foo/bar.txt"))
|
File::create(root.join("foo/bar.txt"))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.write_all(b"test\nfoo")
|
.write_all(b"test\nfoo")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -302,8 +302,8 @@ mod tests {
|
|||||||
&root.as_os_str().to_str().unwrap().into();
|
&root.as_os_str().to_str().unwrap().into();
|
||||||
|
|
||||||
{
|
{
|
||||||
fs::create_dir_all(&root.join("foo/bar")).unwrap();
|
fs::create_dir_all(root.join("foo/bar")).unwrap();
|
||||||
File::create(&root.join("foo/bar/baz.txt"))
|
File::create(root.join("foo/bar/baz.txt"))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.write_all(b"test\nfoo")
|
.write_all(b"test\nfoo")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -170,7 +170,7 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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")?;
|
.write_all(b"test\nfoo")?;
|
||||||
|
|
||||||
assert_eq!(get_statuses(repo_path), (1, 0));
|
assert_eq!(get_statuses(repo_path), (1, 0));
|
||||||
@ -189,7 +189,7 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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")?;
|
.write_all(b"test\nfoo")?;
|
||||||
|
|
||||||
stash_save(repo_path, Some("foo"), true, false)?;
|
stash_save(repo_path, Some("foo"), true, false)?;
|
||||||
@ -213,7 +213,7 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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")?;
|
.write_all(b"test\nfoo")?;
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
@ -231,11 +231,11 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&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)?;
|
stage_add_file(repo_path, file_path1)?;
|
||||||
commit(repo_path, "c1")?;
|
commit(repo_path, "c1")?;
|
||||||
|
|
||||||
File::create(&root.join(file_path1))?
|
File::create(root.join(file_path1))?
|
||||||
.write_all(b"modified")?;
|
.write_all(b"modified")?;
|
||||||
|
|
||||||
//NOTE: apparently `libgit2` works differently to git stash in
|
//NOTE: apparently `libgit2` works differently to git stash in
|
||||||
|
@ -256,12 +256,12 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&root.as_os_str().to_str().unwrap().into();
|
||||||
|
|
||||||
File::create(&root.join(file_path))
|
File::create(root.join(file_path))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.write_all(b"test file1 content")
|
.write_all(b"test file1 content")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
File::create(&root.join(Path::new("file2.txt")))
|
File::create(root.join(Path::new("file2.txt")))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.write_all(b"test file2 content")
|
.write_all(b"test file2 content")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -284,12 +284,12 @@ mod tests {
|
|||||||
get_status(repo_path, s, None).unwrap().len()
|
get_status(repo_path, s, None).unwrap().len()
|
||||||
};
|
};
|
||||||
|
|
||||||
fs::create_dir_all(&root.join("a/d"))?;
|
fs::create_dir_all(root.join("a/d"))?;
|
||||||
File::create(&root.join(Path::new("a/d/f1.txt")))?
|
File::create(root.join(Path::new("a/d/f1.txt")))?
|
||||||
.write_all(b"foo")?;
|
.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")?;
|
.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")?;
|
.write_all(b"foo")?;
|
||||||
|
|
||||||
assert_eq!(status_count(StatusType::WorkingDir), 3);
|
assert_eq!(status_count(StatusType::WorkingDir), 3);
|
||||||
@ -346,12 +346,12 @@ mod tests {
|
|||||||
let repo_path: &RepoPath =
|
let repo_path: &RepoPath =
|
||||||
&root.as_os_str().to_str().unwrap().into();
|
&root.as_os_str().to_str().unwrap().into();
|
||||||
|
|
||||||
fs::create_dir_all(&root.join("a/d"))?;
|
fs::create_dir_all(root.join("a/d"))?;
|
||||||
File::create(&root.join(Path::new("a/d/f1.txt")))?
|
File::create(root.join(Path::new("a/d/f1.txt")))?
|
||||||
.write_all(b"foo")?;
|
.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")?;
|
.write_all(b"foo")?;
|
||||||
File::create(&root.join(Path::new("f3.txt")))?
|
File::create(root.join(Path::new("f3.txt")))?
|
||||||
.write_all(b"foo")?;
|
.write_all(b"foo")?;
|
||||||
|
|
||||||
assert_eq!(get_statuses(repo_path), (3, 0));
|
assert_eq!(get_statuses(repo_path), (3, 0));
|
||||||
|
@ -985,8 +985,7 @@ impl App {
|
|||||||
branch_ref.rsplit('/').next().map_or_else(
|
branch_ref.rsplit('/').next().map_or_else(
|
||||||
|| {
|
|| {
|
||||||
InternalEvent::ShowErrorMsg(format!(
|
InternalEvent::ShowErrorMsg(format!(
|
||||||
"Failed to find the branch name in {}",
|
"Failed to find the branch name in {branch_ref}"
|
||||||
branch_ref
|
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
|name| {
|
|name| {
|
||||||
|
@ -454,10 +454,7 @@ impl BlameFileComponent {
|
|||||||
let line_number_width = self.get_line_number_width();
|
let line_number_width = self.get_line_number_width();
|
||||||
cells.push(
|
cells.push(
|
||||||
Cell::from(format!(
|
Cell::from(format!(
|
||||||
"{:>line_number_width$}{}",
|
"{line_number:>line_number_width$}{VERTICAL}",
|
||||||
line_number,
|
|
||||||
VERTICAL,
|
|
||||||
line_number_width = line_number_width,
|
|
||||||
))
|
))
|
||||||
.style(self.theme.text(true, false)),
|
.style(self.theme.text(true, false)),
|
||||||
);
|
);
|
||||||
@ -483,11 +480,7 @@ impl BlameFileComponent {
|
|||||||
|| NO_AUTHOR.into(),
|
|| NO_AUTHOR.into(),
|
||||||
|hunk| string_width_align(&hunk.author, author_width),
|
|hunk| string_width_align(&hunk.author, author_width),
|
||||||
);
|
);
|
||||||
let author = format!(
|
let author = format!("{truncated_author:MAX_AUTHOR_WIDTH$}");
|
||||||
"{:author_width$}",
|
|
||||||
truncated_author,
|
|
||||||
author_width = MAX_AUTHOR_WIDTH
|
|
||||||
);
|
|
||||||
let time = blame_hunk.map_or_else(String::new, |hunk| {
|
let time = blame_hunk.map_or_else(String::new, |hunk| {
|
||||||
utils::time_to_string(hunk.time, true)
|
utils::time_to_string(hunk.time, true)
|
||||||
});
|
});
|
||||||
|
@ -624,11 +624,7 @@ impl BranchListComponent {
|
|||||||
theme.text(true, selected),
|
theme.text(true, selected),
|
||||||
);
|
);
|
||||||
let span_name = Span::styled(
|
let span_name = Span::styled(
|
||||||
format!(
|
format!("{branch_name:branch_name_length$} "),
|
||||||
"{:w$} ",
|
|
||||||
branch_name,
|
|
||||||
w = branch_name_length
|
|
||||||
),
|
|
||||||
theme.branch(selected, is_head),
|
theme.branch(selected, is_head),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -241,8 +241,7 @@ impl CommitComponent {
|
|||||||
{
|
{
|
||||||
log::error!("pre-commit hook error: {}", e);
|
log::error!("pre-commit hook error: {}", e);
|
||||||
self.queue.push(InternalEvent::ShowErrorMsg(format!(
|
self.queue.push(InternalEvent::ShowErrorMsg(format!(
|
||||||
"pre-commit hook error:\n{}",
|
"pre-commit hook error:\n{e}"
|
||||||
e
|
|
||||||
)));
|
)));
|
||||||
return Ok(CommitResult::Aborted);
|
return Ok(CommitResult::Aborted);
|
||||||
}
|
}
|
||||||
@ -252,8 +251,7 @@ impl CommitComponent {
|
|||||||
{
|
{
|
||||||
log::error!("commit-msg hook error: {}", e);
|
log::error!("commit-msg hook error: {}", e);
|
||||||
self.queue.push(InternalEvent::ShowErrorMsg(format!(
|
self.queue.push(InternalEvent::ShowErrorMsg(format!(
|
||||||
"commit-msg hook error:\n{}",
|
"commit-msg hook error:\n{e}"
|
||||||
e
|
|
||||||
)));
|
)));
|
||||||
return Ok(CommitResult::Aborted);
|
return Ok(CommitResult::Aborted);
|
||||||
}
|
}
|
||||||
@ -276,8 +274,7 @@ impl CommitComponent {
|
|||||||
{
|
{
|
||||||
log::error!("post-commit hook error: {}", e);
|
log::error!("post-commit hook error: {}", e);
|
||||||
self.queue.push(InternalEvent::ShowErrorMsg(format!(
|
self.queue.push(InternalEvent::ShowErrorMsg(format!(
|
||||||
"post-commit hook error:\n{}",
|
"post-commit hook error:\n{e}"
|
||||||
e
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,8 +326,7 @@ impl DiffComponent {
|
|||||||
Span::raw(Cow::from(" (")),
|
Span::raw(Cow::from(" (")),
|
||||||
Span::styled(
|
Span::styled(
|
||||||
Cow::from(format!(
|
Cow::from(format!(
|
||||||
"{}{:}",
|
"{sign}{delta_byte_size:}"
|
||||||
sign, delta_byte_size
|
|
||||||
)),
|
)),
|
||||||
self.theme.diff_line(
|
self.theme.diff_line(
|
||||||
if is_positive {
|
if is_positive {
|
||||||
|
@ -199,11 +199,7 @@ impl RevisionFilesComponent {
|
|||||||
width.saturating_sub(indent_str.len() + path_arrow.len());
|
width.saturating_sub(indent_str.len() + path_arrow.len());
|
||||||
|
|
||||||
let path = format!(
|
let path = format!(
|
||||||
"{}{}{:w$}",
|
"{indent_str}{path_arrow}{path:available_width$}"
|
||||||
indent_str,
|
|
||||||
path_arrow,
|
|
||||||
path,
|
|
||||||
w = available_width
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Span::styled(path, theme.file_tree_item(is_path, selected))
|
Span::styled(path, theme.file_tree_item(is_path, selected))
|
||||||
|
@ -215,10 +215,7 @@ impl StatusTreeComponent {
|
|||||||
w = width as usize
|
w = width as usize
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
format!(
|
format!(" {indent_str}{collapse_char}{string}",)
|
||||||
" {}{}{}",
|
|
||||||
indent_str, collapse_char, string,
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(Span::styled(
|
Some(Span::styled(
|
||||||
|
@ -132,8 +132,7 @@ impl SyntaxTextComponent {
|
|||||||
self.current_file = Some((
|
self.current_file = Some((
|
||||||
path,
|
path,
|
||||||
Either::Right(format!(
|
Either::Right(format!(
|
||||||
"error loading file: {}",
|
"error loading file: {e}"
|
||||||
e
|
|
||||||
)),
|
)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -193,8 +193,7 @@ pub fn confirm_msg_reset() -> String {
|
|||||||
}
|
}
|
||||||
pub fn confirm_msg_reset_lines(lines: usize) -> String {
|
pub fn confirm_msg_reset_lines(lines: usize) -> String {
|
||||||
format!(
|
format!(
|
||||||
"are you sure you want to discard {} selected lines?",
|
"are you sure you want to discard {lines} selected lines?"
|
||||||
lines
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
pub fn confirm_msg_stashdrop(
|
pub fn confirm_msg_stashdrop(
|
||||||
@ -273,8 +272,7 @@ pub fn confirm_msg_force_push(
|
|||||||
branch_ref: &str,
|
branch_ref: &str,
|
||||||
) -> String {
|
) -> String {
|
||||||
format!(
|
format!(
|
||||||
"Confirm force push to branch '{}' ? This may rewrite history.",
|
"Confirm force push to branch '{branch_ref}' ? This may rewrite history."
|
||||||
branch_ref
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
pub fn log_title(_key_config: &SharedKeyConfig) -> String {
|
pub fn log_title(_key_config: &SharedKeyConfig) -> String {
|
||||||
@ -285,10 +283,7 @@ pub fn file_log_title(
|
|||||||
selected: usize,
|
selected: usize,
|
||||||
revisions: usize,
|
revisions: usize,
|
||||||
) -> String {
|
) -> String {
|
||||||
format!(
|
format!("Revisions of '{file_path}' ({selected}/{revisions})")
|
||||||
"Revisions of '{}' ({}/{})",
|
|
||||||
file_path, selected, revisions
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
pub fn blame_title(_key_config: &SharedKeyConfig) -> String {
|
pub fn blame_title(_key_config: &SharedKeyConfig) -> String {
|
||||||
"Blame".to_string()
|
"Blame".to_string()
|
||||||
|
@ -232,8 +232,7 @@ impl Status {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let w = Paragraph::new(format!(
|
let w = Paragraph::new(format!(
|
||||||
"{}{{{}}}",
|
"{ahead_behind}{{{branch_name}}}"
|
||||||
ahead_behind, branch_name
|
|
||||||
))
|
))
|
||||||
.alignment(Alignment::Right);
|
.alignment(Alignment::Right);
|
||||||
|
|
||||||
@ -560,8 +559,7 @@ impl Status {
|
|||||||
item.path.as_str(),
|
item.path.as_str(),
|
||||||
) {
|
) {
|
||||||
self.queue.push(InternalEvent::ShowErrorMsg(format!(
|
self.queue.push(InternalEvent::ShowErrorMsg(format!(
|
||||||
"reset failed:\n{}",
|
"reset failed:\n{e}"
|
||||||
e
|
|
||||||
)));
|
)));
|
||||||
|
|
||||||
false
|
false
|
||||||
|
Loading…
Reference in New Issue
Block a user