From 43905cfa6bed0bd6432e9b15c35d06dadd0c2063 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Fri, 12 Jun 2020 15:04:52 +0200 Subject: [PATCH] cleanup TODO --- asyncgit/src/status.rs | 2 +- asyncgit/src/sync/diff.rs | 12 ++++-------- asyncgit/src/sync/mod.rs | 6 ++++-- asyncgit/src/sync/reset.rs | 4 ++-- asyncgit/src/sync/status.rs | 10 +--------- asyncgit/src/sync/utils.rs | 6 +++--- 6 files changed, 15 insertions(+), 25 deletions(-) diff --git a/asyncgit/src/status.rs b/asyncgit/src/status.rs index 5a73b9dc..16c0afe6 100644 --- a/asyncgit/src/status.rs +++ b/asyncgit/src/status.rs @@ -156,7 +156,7 @@ impl AsyncStatus { include_untracked: bool, ) -> Result { Ok(Status { - items: sync::status::get_status_new( + items: sync::status::get_status( CWD, status_type, include_untracked, diff --git a/asyncgit/src/sync/diff.rs b/asyncgit/src/sync/diff.rs index e0bd303a..a40956a3 100644 --- a/asyncgit/src/sync/diff.rs +++ b/asyncgit/src/sync/diff.rs @@ -298,9 +298,7 @@ mod tests { let root = repo.path().parent().unwrap(); let repo_path = root.as_os_str().to_str().unwrap(); - let res = - get_status(repo_path, StatusType::WorkingDir).unwrap(); - assert_eq!(res.len(), 0); + assert_eq!(get_statuses(repo_path), (0, 0)); fs::create_dir(&root.join("foo")).unwrap(); File::create(&root.join("foo/bar.txt")) @@ -308,9 +306,7 @@ mod tests { .write_all(b"test\nfoo") .unwrap(); - let res = - get_status(repo_path, StatusType::WorkingDir).unwrap(); - assert_eq!(res.len(), 1); + assert_eq!(get_statuses(repo_path), (1, 0)); let diff = get_diff(repo_path, "foo/bar.txt".to_string(), false) @@ -393,8 +389,8 @@ mod tests { .unwrap(); } - let res = - get_status(repo_path, StatusType::WorkingDir).unwrap(); + let res = get_status(repo_path, StatusType::WorkingDir, true) + .unwrap(); assert_eq!(res.len(), 1); assert_eq!(res[0].path, "bar.txt"); diff --git a/asyncgit/src/sync/mod.rs b/asyncgit/src/sync/mod.rs index 4237672e..aa8538ed 100644 --- a/asyncgit/src/sync/mod.rs +++ b/asyncgit/src/sync/mod.rs @@ -79,10 +79,12 @@ mod tests { /// helper returning amount of files with changes in the (wd,stage) pub fn get_statuses(repo_path: &str) -> (usize, usize) { ( - get_status(repo_path, StatusType::WorkingDir) + get_status(repo_path, StatusType::WorkingDir, true) + .unwrap() + .len(), + get_status(repo_path, StatusType::Stage, true) .unwrap() .len(), - get_status(repo_path, StatusType::Stage).unwrap().len(), ) } diff --git a/asyncgit/src/sync/reset.rs b/asyncgit/src/sync/reset.rs index 30a2961c..b0247b88 100644 --- a/asyncgit/src/sync/reset.rs +++ b/asyncgit/src/sync/reset.rs @@ -96,8 +96,8 @@ mod tests { let root = repo.path().parent().unwrap(); let repo_path = root.as_os_str().to_str().unwrap(); - let res = - get_status(repo_path, StatusType::WorkingDir).unwrap(); + let res = get_status(repo_path, StatusType::WorkingDir, true) + .unwrap(); assert_eq!(res.len(), 0); let file_path = root.join("bar.txt"); diff --git a/asyncgit/src/sync/status.rs b/asyncgit/src/sync/status.rs index 8b5d44cf..2a9f7915 100644 --- a/asyncgit/src/sync/status.rs +++ b/asyncgit/src/sync/status.rs @@ -84,18 +84,10 @@ impl Into for StatusType { } } -/// TODO: migrate +/// pub fn get_status( repo_path: &str, status_type: StatusType, -) -> Result> { - get_status_new(repo_path, status_type, true) -} - -/// TODO: migrate -pub fn get_status_new( - repo_path: &str, - status_type: StatusType, include_untracked: bool, ) -> Result> { scope_time!("get_status"); diff --git a/asyncgit/src/sync/utils.rs b/asyncgit/src/sync/utils.rs index 16f6634c..fa7d3824 100644 --- a/asyncgit/src/sync/utils.rs +++ b/asyncgit/src/sync/utils.rs @@ -232,7 +232,7 @@ mod tests { let repo_path = root.as_os_str().to_str().unwrap(); let status_count = |s: StatusType| -> usize { - get_status(repo_path, s).unwrap().len() + get_status(repo_path, s, true).unwrap().len() }; fs::create_dir_all(&root.join("a/d"))?; @@ -261,7 +261,7 @@ mod tests { let repo_path = root.as_os_str().to_str().unwrap(); let status_count = |s: StatusType| -> usize { - get_status(repo_path, s).unwrap().len() + get_status(repo_path, s, true).unwrap().len() }; let full_path = &root.join(file_path); @@ -295,7 +295,7 @@ mod tests { let repo_path = root.as_os_str().to_str().unwrap(); let status_count = |s: StatusType| -> usize { - get_status(repo_path, s).unwrap().len() + get_status(repo_path, s, true).unwrap().len() }; let sub = &root.join("sub");