Skip to content

Commit

Permalink
Set upstream on push, and use --force-with-lease
Browse files Browse the repository at this point in the history
  • Loading branch information
anorth committed Jan 16, 2020
1 parent 1d323e4 commit e6af65c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions gflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
Upcoming features fixes:
- add --help option to describe commands
- add squash option to land
- add delete branch/s option to land
- count the diff stat size and append a description to PR title
Expand Down Expand Up @@ -126,7 +127,7 @@ def do_publish(self, *args):
if source == 'master':
raise FlowError("Refusing to publish master branch, use git push directly.")

self._push(source, pargs.no_verify)
self._push(source, no_verify=pargs.no_verify, set_upstream=True)

def do_unpublish(self, *args):
"""
Expand Down Expand Up @@ -210,10 +211,12 @@ def do_land(self, *args):
def _current_branch(self) -> str:
return self._git_cap("rev-parse", "--abbrev-ref", "HEAD").strip()

def _push(self, branch, no_verify=False):
extra_args = ["--force"]
def _push(self, branch, no_verify=False, set_upstream=False):
extra_args = ["--force-with-lease"]
if no_verify:
extra_args.append("--no-verify")
if set_upstream:
extra_args.append("--set-upstream")

return self._git_run("push", "origin", "{0}:{0}".format(branch), *extra_args)

Expand Down

0 comments on commit e6af65c

Please sign in to comment.