diff --git a/.devops/deployer.py b/.devops/deployer.py index 48a21bc..5525805 100644 --- a/.devops/deployer.py +++ b/.devops/deployer.py @@ -117,14 +117,36 @@ class Deployer: if not self.run_command("git pull", cwd=repo_path): return False - # 更新所有子模块 + # 初始化子模块(如果还没初始化) if not self.run_command("git submodule update --init --recursive", cwd=repo_path): return False + # 更新所有子模块到各自配置的分支 + self.logger.info("更新所有子模块到最新代码...") + if not self.update_all_submodules(repo_path): + return False + self.logger.info("主仓库更新成功") return True + def update_all_submodules(self, repo_path): + """更新所有子模块到各自配置的分支""" + # 遍历所有配置的仓库,更新子模块到对应分支 + for repo_config in self.config['repositories']: + branch = repo_config['branch'] + submodule_path = repo_config['path'] + + self.logger.info(f"更新子模块 {repo_config['name']} 到分支 {branch}") + + # 构建命令:进入子模块,切换分支并拉取 + cmd = f"cd {submodule_path} && git checkout {branch} && git pull origin {branch}" + if not self.run_command(cmd, cwd=repo_path, timeout=300): + self.logger.warning(f"子模块 {repo_config['name']} 更新失败,继续处理其他子模块") + continue + + return True + def update_submodule(self, repo_config): """更新指定的子模块""" repo_path = self.runtime_path / 'a-cloud-all'