Skip to content

Commit 7122a15

Browse files
ambvpablogsal
andauthored
Use git push -f when pushing into backport branches (#32)
This solves issues with stale remote branches without having to keep track of them explicitly. Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
1 parent f1b6e99 commit 7122a15

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

cherry_picker/cherry_picker.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,11 @@ def push_to_remote(self, base_branch, head_branch, commit_message=""):
284284
""" git push <origin> <branchname> """
285285
set_state(WORKFLOW_STATES.PUSHING_TO_REMOTE)
286286

287-
cmd = ["git", "push", self.pr_remote, f"{head_branch}:{head_branch}"]
287+
cmd = ["git", "push"]
288+
if head_branch.startswith("backport-"):
289+
# Overwrite potential stale backport branches with extreme prejudice.
290+
cmd.append("--force-with-lease")
291+
cmd += [self.pr_remote, f"{head_branch}:{head_branch}"]
288292
try:
289293
self.run_cmd(cmd)
290294
set_state(WORKFLOW_STATES.PUSHED_TO_REMOTE)

0 commit comments

Comments
 (0)