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
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:
parent
75fe8dfc0c
commit
50301dfb8c
@ -158,17 +158,15 @@ class GitManager:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def push(self, branch_name: Optional[str] = None) -> bool:
|
def push(self, branch_name: Optional[str] = None) -> bool:
|
||||||
"""推送到远程"""
|
"""推送到远程(自动设置上游跟踪分支)"""
|
||||||
if not self.repo:
|
if not self.repo:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
branch = branch_name or self.repo.active_branch.name
|
||||||
origin = self.repo.remotes.origin
|
origin = self.repo.remotes.origin
|
||||||
if branch_name:
|
origin.push(refspec=f"{branch}:{branch}", set_upstream=True)
|
||||||
origin.push(branch_name)
|
logger.info(f"推送成功: {branch}")
|
||||||
else:
|
|
||||||
origin.push()
|
|
||||||
logger.info("推送成功")
|
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"推送失败: {e}")
|
logger.error(f"推送失败: {e}")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user