fix: 修复add命令检测workdir(而非curDir)中deleted files的问题

This commit is contained in:
mrbeanc
2023-12-22 14:49:52 +08:00
parent 49a7220ad8
commit b9b8d9c704
3 changed files with 12 additions and 6 deletions

View File

@@ -144,6 +144,12 @@ pub fn is_inside_dir(file: &Path, dir: &Path) -> bool {
}
}
/// 检测dir是否是file的父目录 (不论文件是否存在)
pub fn is_parent_dir(file: &Path, dir: &Path) -> bool {
let file = get_absolute_path(file);
file.starts_with(dir)
}
/// 检查文件是否在工作区内, 若不存在则false
pub fn is_inside_workdir(file: &Path) -> bool {
is_inside_dir(file, &get_working_dir().unwrap())