This commit is contained in:
孙小云 2026-01-10 13:27:53 +08:00
parent 12fb2130e9
commit c73482e827
1 changed files with 6 additions and 1 deletions

View File

@ -298,6 +298,11 @@ class Deployer:
if not self.run_command(f'git commit -m "{commit_msg}"', cwd=repo_path): if not self.run_command(f'git commit -m "{commit_msg}"', cwd=repo_path):
return False return False
# 推送前先拉取远程最新代码
self.logger.info("推送前先拉取远程最新代码...")
if not self.run_command(f"git pull --rebase origin {self.main_repo_branch}", cwd=repo_path):
self.logger.warning("拉取远程代码失败,尝试直接推送")
# 推送到远程 # 推送到远程
if not self.run_command(f"git push origin {self.main_repo_branch}", cwd=repo_path): if not self.run_command(f"git push origin {self.main_repo_branch}", cwd=repo_path):
self.logger.warning("推送失败,但部署已完成") self.logger.warning("推送失败,但部署已完成")