mirror of
https://github.com/MrBeanCpp/MIT.git
synced 2026-07-02 01:06:03 +08:00
恢复index更改
This commit is contained in:
@@ -55,7 +55,7 @@ pub struct Index {
|
||||
|
||||
impl Index {
|
||||
/// 从index文件加载
|
||||
pub fn new() -> Index {
|
||||
fn new() -> Index {
|
||||
let mut index = Index::default();
|
||||
index.load();
|
||||
return index;
|
||||
@@ -67,7 +67,7 @@ impl Index {
|
||||
unsafe { &mut INSTANCE }
|
||||
}
|
||||
|
||||
/// 重置index 从文件重新加载,主要用于测试,防止单例模式的影响
|
||||
/// 重置index,主要用于测试,防止单例模式的影响
|
||||
pub fn reload() {
|
||||
let index = Index::get_instance();
|
||||
index.load();
|
||||
@@ -224,14 +224,14 @@ mod tests {
|
||||
#[test]
|
||||
fn test_load() {
|
||||
test_util::setup_test_with_clean_mit();
|
||||
let index = Index::new();
|
||||
let index = Index::get_instance();
|
||||
println!("{:?}", index);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_save() {
|
||||
test_util::setup_test_with_clean_mit();
|
||||
let mut index = Index::new();
|
||||
let index = Index::get_instance();
|
||||
let path = PathBuf::from("../mit_test_storage/.mit/HEAD"); //测试../相对路径的处理
|
||||
index.add(path.clone(), FileMetaData::new(&Blob::new(&path), &path));
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_new() {
|
||||
test_util::setup_test_with_clean_mit();
|
||||
let mut index = Index::new();
|
||||
let index = Index::get_instance();
|
||||
for test_file in vec!["b.txt", "mit_src/a.txt", "test/test.txt"] {
|
||||
let test_file = PathBuf::from(test_file);
|
||||
test_util::ensure_test_file(&test_file, None);
|
||||
@@ -181,7 +181,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_load() {
|
||||
test_util::setup_test_with_clean_mit();
|
||||
let mut index = Index::new();
|
||||
let index = Index::get_instance();
|
||||
let test_files = vec!["b.txt", "mit_src/a.txt"];
|
||||
for test_file in test_files.clone() {
|
||||
let test_file = PathBuf::from(test_file);
|
||||
@@ -201,7 +201,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_get_recursive_file_entries() {
|
||||
test_util::setup_test_with_clean_mit();
|
||||
let mut index = Index::new();
|
||||
let index = Index::get_instance();
|
||||
let mut test_files = vec![PathBuf::from("b.txt"), PathBuf::from("mit_src/a.txt")];
|
||||
for test_file in test_files.clone() {
|
||||
test_util::ensure_test_file(&test_file, None);
|
||||
@@ -229,7 +229,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_get_recursive_blobs() {
|
||||
test_util::setup_test_with_clean_mit();
|
||||
let mut index = Index::new();
|
||||
let index = Index::get_instance();
|
||||
let test_files = vec!["b.txt", "mit_src/a.txt"];
|
||||
let mut test_blobs = vec![];
|
||||
for test_file in test_files.clone() {
|
||||
|
||||
Reference in New Issue
Block a user