0
0

修复了拉取出现的bug,完善了改名功能

This commit is contained in:
xubing
2025-12-06 18:05:35 +08:00
parent 46c184b920
commit 11c405f79a
10 changed files with 650 additions and 98 deletions

View File

@@ -83,7 +83,7 @@ class GitService {
static async cloneRepository(url, localPath, branch = 'main', onProgress, username, token) {
const parentDir = path.dirname(localPath);
await fs.promises.mkdir(parentDir, { recursive: true });
// 检查目录是否已存在且非空(不变)
// 检查目录是否已存在且非空
let dirExists = false;
try {
await fs.promises.access(localPath);
@@ -94,7 +94,10 @@ class GitService {
}
if (dirExists) {
const dirContents = await fs.promises.readdir(localPath);
if (dirContents.length > 0 && dirContents.some(item => item !== '.git')) {
// 修正后的逻辑:过滤掉所有以 "." 开头的隐藏文件/目录。
// 只有当存在非 "." 开头的文件或目录时,才阻止克隆。
const nonBenignFiles = dirContents.filter(item => !item.startsWith('.'));
if (nonBenignFiles.length > 0) {
throw new Error('目标目录不为空,请清空目录或选择其他路径');
}
}