Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(636)

Unified Diff: git_cl.py

Issue 15025003: Add colors to git cl comments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix import Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cl.py
diff --git a/git_cl.py b/git_cl.py
index a93a04b27ac2b1888b4f49520f52387ef0ef04c6..b34edcf38df385ee4be9566372e16259c696c6d4 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -24,6 +24,7 @@ except ImportError:
pass
+from third_party import colorama
from third_party import upload
import breakpad # pylint: disable=W0611
import fix_encoding
@@ -41,6 +42,8 @@ DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup'
GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingNewGit'
CHANGE_ID = 'Change-Id:'
+# Shortcut since it quickly becomes redundant.
+Fore = colorama.Fore
# Initialized in main()
settings = None
@@ -1101,7 +1104,17 @@ def CMDcomments(parser, args):
if cl.GetIssue():
data = cl.RpcServer().get_issue_properties(cl.GetIssue(), True)
for message in sorted(data['messages'], key=lambda x: x['date']):
- print '\n%s %s' % (message['date'].split('.', 1)[0], message['sender'])
+ if message['disapproval']:
+ color = Fore.RED
+ elif message['approval']:
+ color = Fore.GREEN
+ elif message['sender'] == data['owner_email']:
+ color = Fore.MAGENTA
+ else:
+ color = Fore.BLUE
+ print '\n%s%s %s%s' % (
+ color, message['date'].split('.', 1)[0], message['sender'],
+ Fore.RESET)
if message['text'].strip():
print '\n'.join(' ' + l for l in message['text'].splitlines())
return 0
@@ -1994,6 +2007,7 @@ def main(argv):
'\nYour python version %s is unsupported, please upgrade.\n' %
sys.version.split(' ', 1)[0])
return 2
+
# Reload settings.
global settings
settings = Settings()
@@ -2040,5 +2054,8 @@ def main(argv):
if __name__ == '__main__':
+ # These affect sys.stdout so do it outside of main() to simplify mocks in
+ # unit testing.
fix_encoding.fix_encoding()
+ colorama.init()
sys.exit(main(sys.argv[1:]))
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698