rebase: add --fail-fast support
Lets switch the default rebase behavior to align with our new sync
behavior: we try to rebase all projects by default and exit/summarize
things at the very end if there were any errors. Or if people want
to exit immediately, they can use the new --fail-fast option.
Change-Id: I436ac563f972b45de6ce9ad74da1e4870e584902
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/238553
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
Tested-by: Mike Frysinger <vapier@google.com>
diff --git a/subcmds/rebase.py b/subcmds/rebase.py
index 9bc4460..346eb9c 100644
--- a/subcmds/rebase.py
+++ b/subcmds/rebase.py
@@ -37,6 +37,9 @@
dest="interactive", action="store_true",
help="interactive rebase (single project only)")
+ p.add_option('--fail-fast',
+ dest='fail_fast', action='store_true',
+ help='Stop rebasing after first error is hit')
p.add_option('-f', '--force-rebase',
dest='force_rebase', action='store_true',
help='Pass --force-rebase to git rebase')
@@ -88,7 +91,11 @@
if opt.interactive:
common_args.append('-i')
+ ret = 0
for project in all_projects:
+ if ret and opt.fail_fast:
+ break
+
cb = project.CurrentBranch
if not cb:
if one_project:
@@ -127,13 +134,19 @@
stash_args = ["stash"]
if GitCommand(project, stash_args).Wait() != 0:
- return 1
+ ret += 1
+ continue
if GitCommand(project, args).Wait() != 0:
- return 1
+ ret += 1
+ continue
if needs_stash:
stash_args.append('pop')
stash_args.append('--quiet')
if GitCommand(project, stash_args).Wait() != 0:
- return 1
+ ret += 1
+
+ if ret:
+ print('error: %i projects had errors' % (ret,), file=sys.stderr)
+ return ret