fix(git-manager): set upstream when pushing new branches
All checks were successful
Build and Deploy Log Center / build-and-deploy (push) Successful in 3m9s

push() was failing for new fix branches because they had no upstream
tracking branch. Now uses set_upstream=True with explicit refspec.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
zyc 2026-02-24 13:50:31 +08:00
parent 75fe8dfc0c
commit 50301dfb8c

View File

@ -158,17 +158,15 @@ class GitManager:
return False
def push(self, branch_name: Optional[str] = None) -> bool:
"""推送到远程"""
"""推送到远程(自动设置上游跟踪分支)"""
if not self.repo:
return False
try:
branch = branch_name or self.repo.active_branch.name
origin = self.repo.remotes.origin
if branch_name:
origin.push(branch_name)
else:
origin.push()
logger.info("推送成功")
origin.push(refspec=f"{branch}:{branch}", set_upstream=True)
logger.info(f"推送成功: {branch}")
return True
except Exception as e:
logger.error(f"推送失败: {e}")