diff --git a/.devops/deployer.py b/.devops/deployer.py index 0fa1d78..fbdc0e1 100644 --- a/.devops/deployer.py +++ b/.devops/deployer.py @@ -71,8 +71,16 @@ class Deployer: # 直接使用 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("主仓库不存在,开始克隆...") + + # 如果目录存在但不是 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) # 克隆到 runtime 目录