From e37aa5f331aa39776d5db1a1f816b66496f60e0c Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 23 Sep 2019 19:14:13 -0400 Subject: [PATCH] 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 Tested-by: Mike Frysinger --- subcmds/rebase.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/subcmds/rebase.py b/subcmds/rebase.py index 346eb9cd..dcb8b2a3 100644 --- a/subcmds/rebase.py +++ b/subcmds/rebase.py @@ -17,9 +17,18 @@ from __future__ import print_function import sys +from color import Coloring from command import Command 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): common = True helpSummary = "Rebase local branches on upstream branch" @@ -91,6 +100,10 @@ branch but need to incorporate new upstream changes "underneath" them. if opt.interactive: common_args.append('-i') + config = self.manifest.manifestProject.config + out = RebaseColoring(config) + out.redirect(sys.stdout) + ret = 0 for project in all_projects: if ret and opt.fail_fast: @@ -121,8 +134,10 @@ branch but need to incorporate new upstream changes "underneath" them. args.append(upbranch.LocalMerge) - print('# %s: rebasing %s -> %s' - % (project.relpath, cb, upbranch.LocalMerge), file=sys.stderr) + out.project('project %s: rebasing %s -> %s', + project.relpath, cb, upbranch.LocalMerge) + out.nl() + out.flush() needs_stash = False if opt.auto_stash: @@ -148,5 +163,7 @@ branch but need to incorporate new upstream changes "underneath" them. ret += 1 if ret: - print('error: %i projects had errors' % (ret,), file=sys.stderr) + out.fail('%i projects had errors', ret) + out.nl() + return ret