Skip to content

Commit

Permalink
Use git push -f when pushing into backport branches (#32)
Browse files Browse the repository at this point in the history
This solves issues with stale remote branches without having to keep track of
them explicitly.

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
  • Loading branch information
ambv and pablogsal authored Aug 2, 2021
1 parent f1b6e99 commit 7122a15
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cherry_picker/cherry_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,11 @@ def push_to_remote(self, base_branch, head_branch, commit_message=""):
""" git push <origin> <branchname> """
set_state(WORKFLOW_STATES.PUSHING_TO_REMOTE)

cmd = ["git", "push", self.pr_remote, f"{head_branch}:{head_branch}"]
cmd = ["git", "push"]
if head_branch.startswith("backport-"):
# Overwrite potential stale backport branches with extreme prejudice.
cmd.append("--force-with-lease")
cmd += [self.pr_remote, f"{head_branch}:{head_branch}"]
try:
self.run_cmd(cmd)
set_state(WORKFLOW_STATES.PUSHED_TO_REMOTE)
Expand Down

0 comments on commit 7122a15

Please sign in to comment.