From 4a07798c826efd3c85b72acaf51932edc628220d Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 23 Sep 2019 18:54:30 -0400 Subject: [PATCH] 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 Tested-by: Mike Frysinger --- subcmds/rebase.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/subcmds/rebase.py b/subcmds/rebase.py index 9bc4460c..346eb9cd 100644 --- a/subcmds/rebase.py +++ b/subcmds/rebase.py @@ -37,6 +37,9 @@ branch but need to incorporate new upstream changes "underneath" them. 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 @@ branch but need to incorporate new upstream changes "underneath" them. 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 @@ branch but need to incorporate new upstream changes "underneath" them. 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