清理警告,删除不需要的util,注释暂时不用的成员函数,为仅测试函数加宏

This commit is contained in:
HouXiaoxuan
2023-12-28 22:45:19 +08:00
parent f88ab0e33a
commit cc428bcae2
4 changed files with 38 additions and 69 deletions

View File

@@ -29,6 +29,7 @@ impl Commit {
pub fn get_date(&self) -> String {
util::format_time(&self.date)
}
#[cfg(test)]
pub fn get_tree_hash(&self) -> String {
self.tree.clone()
}
@@ -44,9 +45,9 @@ impl Commit {
pub fn get_author(&self) -> String {
self.author.clone()
}
pub fn get_committer(&self) -> String {
self.committer.clone()
}
// pub fn get_committer(&self) -> String {
// self.committer.clone()
// }
pub fn new(index: &Index, parent: Vec<Hash>, message: String) -> Commit {
let mut tree = Tree::new(index);

View File

@@ -68,6 +68,7 @@ impl Index {
}
/// 重置index主要用于测试防止单例模式的影响
#[cfg(test)]
pub fn reload() {
let index = Index::get_instance();
index.load();
@@ -115,16 +116,16 @@ impl Index {
self.contains(path)
}
/// 与暂存区比较,获取工作区中被删除的文件
pub fn get_deleted_files(&self, dir: &Path) -> Vec<PathBuf> {
let mut files = Vec::new();
self.entries.keys().for_each(|file| {
if !file.exists() && util::is_sub_path(file, dir) {
files.push(file.clone());
}
});
files
}
// /// 与暂存区比较,获取工作区中被删除的文件
// pub fn get_deleted_files(&self, dir: &Path) -> Vec<PathBuf> {
// let mut files = Vec::new();
// self.entries.keys().for_each(|file| {
// if !file.exists() && util::is_sub_path(file, dir) {
// files.push(file.clone());
// }
// });
// files
// }
/// 与暂存区比较确定文件自上次add以来是否被编辑内容不一定修改还需要算hash
pub fn is_modified(&self, file: &Path) -> bool {
@@ -201,7 +202,8 @@ impl Index {
self.entries.clone()
}
pub fn is_empty(&self) -> bool {
#[cfg(test)]
fn is_empty(&self) -> bool {
self.entries.is_empty()
}
}