处理 runtime 目录已存在但不是 Git 仓库的情况
This commit is contained in:
parent
dd4ce57388
commit
e56fb36ad3
|
|
@ -71,8 +71,16 @@ class Deployer:
|
||||||
# 直接使用 runtime_path 作为仓库路径
|
# 直接使用 runtime_path 作为仓库路径
|
||||||
repo_path = self.runtime_path
|
repo_path = self.runtime_path
|
||||||
|
|
||||||
if not repo_path.exists() or not (repo_path / '.git').exists():
|
# 检查是否是有效的 Git 仓库
|
||||||
|
if not (repo_path / '.git').exists():
|
||||||
self.logger.info("主仓库不存在,开始克隆...")
|
self.logger.info("主仓库不存在,开始克隆...")
|
||||||
|
|
||||||
|
# 如果目录存在但不是 Git 仓库,先删除
|
||||||
|
if repo_path.exists():
|
||||||
|
self.logger.warning(f"目录 {repo_path} 已存在但不是 Git 仓库,将被删除")
|
||||||
|
shutil.rmtree(repo_path)
|
||||||
|
|
||||||
|
# 确保父目录存在
|
||||||
repo_path.parent.mkdir(parents=True, exist_ok=True)
|
repo_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
# 克隆到 runtime 目录
|
# 克隆到 runtime 目录
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue