Skip to content

Commit

Permalink
update push command
Browse files Browse the repository at this point in the history
  • Loading branch information
zackees committed Aug 1, 2024
1 parent 0cc61e3 commit aae8975
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/zcmds/cmds/common/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
import warnings

from git import Repo
from git import Repo, GitCommandError

from zcmds.util.say import say

Expand Down Expand Up @@ -47,11 +47,20 @@ def main() -> int:
repo = Repo(".")
original_branch = repo.active_branch
# fetch the repo
repo.git.fetch()
rtn = repo.git.fetch()
print(rtn)
# can rebase succeed?
# _todo: check if rebase succeeds
# check if head has changed
repo.git.push("origin", original_branch)
try:
repo.git.push("origin", original_branch)
except GitCommandError as e:
if "no upstream branch" in str(e).lower():
warn(f"No upstream branch found for {original_branch}. Push failed, but returning 0 as requested.")
return 0
else:
warn(f"Push failed: {e}")
return 1
return 0


Expand Down

0 comments on commit aae8975

Please sign in to comment.