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>
This commit is contained in:
Mike Frysinger 2019-09-23 18:54:30 -04:00
parent fb527e3f52
commit 4a07798c82

View File

@ -37,6 +37,9 @@ branch but need to incorporate new upstream changes "underneath" them.
dest="interactive", action="store_true", dest="interactive", action="store_true",
help="interactive rebase (single project only)") 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', p.add_option('-f', '--force-rebase',
dest='force_rebase', action='store_true', dest='force_rebase', action='store_true',
help='Pass --force-rebase to git rebase') help='Pass --force-rebase to git rebase')
@ -88,7 +91,11 @@ branch but need to incorporate new upstream changes "underneath" them.
if opt.interactive: if opt.interactive:
common_args.append('-i') common_args.append('-i')
ret = 0
for project in all_projects: for project in all_projects:
if ret and opt.fail_fast:
break
cb = project.CurrentBranch cb = project.CurrentBranch
if not cb: if not cb:
if one_project: if one_project:
@ -127,13 +134,19 @@ branch but need to incorporate new upstream changes "underneath" them.
stash_args = ["stash"] stash_args = ["stash"]
if GitCommand(project, stash_args).Wait() != 0: if GitCommand(project, stash_args).Wait() != 0:
return 1 ret += 1
continue
if GitCommand(project, args).Wait() != 0: if GitCommand(project, args).Wait() != 0:
return 1 ret += 1
continue
if needs_stash: if needs_stash:
stash_args.append('pop') stash_args.append('pop')
stash_args.append('--quiet') stash_args.append('--quiet')
if GitCommand(project, stash_args).Wait() != 0: 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