diff --git a/src/store.rs b/src/store.rs index 9dbc452..24e3a23 100644 --- a/src/store.rs +++ b/src/store.rs @@ -71,7 +71,6 @@ impl Store { let mut path = self.store_path.clone(); path.push("objects"); path.push(&hash); - println!("Saved to: [{}]", path.display()); match std::fs::write(path, content) { Ok(_) => hash, Err(_) => panic!("储存库疑似损坏,无法写入文件"), diff --git a/src/utils/util.rs b/src/utils/util.rs index 997ab10..908d1b0 100644 --- a/src/utils/util.rs +++ b/src/utils/util.rs @@ -52,6 +52,9 @@ pub fn setup_test_with_mit() { pub fn setup_test_with_clean_mit() { setup_test_without_mit(); let _ = crate::commands::init::init(); + list_workdir_files().iter().for_each(|path| { + fs::remove_file(path).unwrap(); + }); } pub fn setup_test_without_mit() { @@ -77,6 +80,13 @@ pub fn ensure_test_file(path: &Path, content: option::Option<&str>) { } } +pub fn ensure_no_file(path: &Path) { + // 以测试目录为根目录,删除文件 + if path.exists() { + fs::remove_file(get_working_dir().unwrap().join(path)).unwrap(); + } +} + /* tools for mit */ pub fn calc_hash(data: &String) -> String { let mut hasher = Sha1::new();