rebase: add basic coloring output

This uses coloring style like we use in grep/forall already.

Change-Id: I317e2e47567a30c513083c48e7c7c40b091bb29a
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/238555
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
Mike Frysinger 2019-09-23 19:14:13 -04:00
parent 4a07798c82
commit e37aa5f331

View File

@ -17,9 +17,18 @@
from __future__ import print_function from __future__ import print_function
import sys import sys
from color import Coloring
from command import Command from command import Command
from git_command import GitCommand from git_command import GitCommand
class RebaseColoring(Coloring):
def __init__(self, config):
Coloring.__init__(self, config, 'rebase')
self.project = self.printer('project', attr='bold')
self.fail = self.printer('fail', fg='red')
class Rebase(Command): class Rebase(Command):
common = True common = True
helpSummary = "Rebase local branches on upstream branch" helpSummary = "Rebase local branches on upstream branch"
@ -91,6 +100,10 @@ branch but need to incorporate new upstream changes "underneath" them.
if opt.interactive: if opt.interactive:
common_args.append('-i') common_args.append('-i')
config = self.manifest.manifestProject.config
out = RebaseColoring(config)
out.redirect(sys.stdout)
ret = 0 ret = 0
for project in all_projects: for project in all_projects:
if ret and opt.fail_fast: if ret and opt.fail_fast:
@ -121,8 +134,10 @@ branch but need to incorporate new upstream changes "underneath" them.
args.append(upbranch.LocalMerge) args.append(upbranch.LocalMerge)
print('# %s: rebasing %s -> %s' out.project('project %s: rebasing %s -> %s',
% (project.relpath, cb, upbranch.LocalMerge), file=sys.stderr) project.relpath, cb, upbranch.LocalMerge)
out.nl()
out.flush()
needs_stash = False needs_stash = False
if opt.auto_stash: if opt.auto_stash:
@ -148,5 +163,7 @@ branch but need to incorporate new upstream changes "underneath" them.
ret += 1 ret += 1
if ret: if ret:
print('error: %i projects had errors' % (ret,), file=sys.stderr) out.fail('%i projects had errors', ret)
out.nl()
return ret return ret