From 12fb2130e97cce0c01c9b4f0441fdc2e64dfb9a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B0=8F=E4=BA=91?= Date: Sat, 10 Jan 2026 13:11:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=B9=E5=99=A8=E5=8C=96?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devops/deployer.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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'