def push_repo(repo, branch, remote='origin', remote_branch=None):
"""
Pushes the repo up to the remote. It will set
the upstream to the remote branch.
:param Repo repo: The repo you wish to push
:param unicode branch: The branch being pushed
:param unicode remote: The remote to use (e.g. ``'origin'``
:param unicode remote_branch: The remote branch. Defaults
to the `branch` parameter
:return: None
:raises: PushFailedException
"""
remote_branch = remote_branch or branch
_checkout_branch(repo, branch)
_LOG.info("Pushing all commits to remote '{0}'".format(remote))
remote = _get_remote(repo, remote)
try:
remote.push(remote_branch, set_upstream=True)
except GitCommandError as e:
_LOG.error(str(e))
raise PushFailedException('Uh oh, it seems like something went'
' wrong with the push. "{0}"'.format(str(e)))
评论列表
文章目录