From c44ad093092f71320c6311cc1fc3de9171f6bd0c Mon Sep 17 00:00:00 2001 From: Jeroen Dhollander Date: Tue, 20 Aug 2024 10:28:41 +0200 Subject: Add a `--rebase` option to sync command Previously repo would abort a sync if there were published changes not merged upstream. The --rebase option allows the modification of published commits. This is a copy of http://go/grev/369694 with the merge conflicts resolved. Bug: 40014610 Change-Id: Idac8199400346327b530abea33f1ed794e5bb4c2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/435838 Reviewed-by: Josip Sokcevic Tested-by: Jeroen Dhollander Commit-Queue: Jeroen Dhollander --- project.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'project.py') diff --git a/project.py b/project.py index 28b19414..25a8cdcd 100644 --- a/project.py +++ b/project.py @@ -1535,6 +1535,7 @@ class Project: syncbuf, force_sync=False, force_checkout=False, + force_rebase=False, submodules=False, errors=None, verbose=False, @@ -1680,14 +1681,15 @@ class Project: if pub: not_merged = self._revlist(not_rev(revid), pub) if not_merged: - if upstream_gain: + if upstream_gain and not force_rebase: # The user has published this branch and some of those # commits are not yet merged upstream. We do not want # to rewrite the published commits so we punt. fail( LocalSyncFail( "branch %s is published (but not merged) and is " - "now %d commits behind" + "now %d commits behind. Fix this manually or rerun " + "with the --rebase option to force a rebase." % (branch.name, len(upstream_gain)), project=self.name, ) -- cgit v1.2.3-54-g00ecf