mirror of
https://github.com/MrBeanCpp/MIT.git
synced 2026-07-02 09:16:03 +08:00
清理警告,删除不需要的util,注释暂时不用的成员函数,为仅测试函数加宏
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user