mirror of
https://github.com/MrBeanCpp/MIT.git
synced 2026-04-24 19:01:26 +08:00
fix 会无意间删掉.mit
This commit is contained in:
@@ -108,18 +108,22 @@ pub fn restore_worktree(filter: Option<&Vec<PathBuf>>, target_blobs: &Vec<(PathB
|
|||||||
// 出现在filter中的目录的子目录如果已经是空目录,需要删除
|
// 出现在filter中的目录的子目录如果已经是空目录,需要删除
|
||||||
for path in &input_paths {
|
for path in &input_paths {
|
||||||
if path.is_dir() && util::list_files(path).unwrap().is_empty() {
|
if path.is_dir() && util::list_files(path).unwrap().is_empty() {
|
||||||
if path != &util::get_working_dir().unwrap() {
|
if !util::check_root_dir(path) {
|
||||||
fs::remove_dir_all(path).unwrap();
|
fs::remove_dir_all(path).unwrap();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for sub_path in util::list_files(path).unwrap() {
|
for sub_path in util::list_subpath(path).unwrap() {
|
||||||
if sub_path.is_dir() && util::list_files(&sub_path).unwrap().is_empty() {
|
if sub_path.is_dir()
|
||||||
fs::remove_dir_all(&sub_path).unwrap();
|
&& util::list_files(&sub_path).unwrap().is_empty()
|
||||||
|
&& !util::check_root_dir(&sub_path)
|
||||||
|
{
|
||||||
|
fs::remove_dir_all(sub_path).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 根据filter restore staged */
|
/** 根据filter restore staged */
|
||||||
pub fn restore_index(filter: Option<&Vec<PathBuf>>, target_blobs: &Vec<(PathBuf, Hash)>) {
|
pub fn restore_index(filter: Option<&Vec<PathBuf>>, target_blobs: &Vec<(PathBuf, Hash)>) {
|
||||||
let input_paths = preprocess_filters(filter); //预处理filter 将None转化为workdir
|
let input_paths = preprocess_filters(filter); //预处理filter 将None转化为workdir
|
||||||
|
|||||||
Reference in New Issue
Block a user