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

Unified Diff: git_cl.py

Issue 1342003002: Add -j flag to git cl comments to get JSON summary of CL comments (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 5 years, 3 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 | no next file » | 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 9fcc3b75269b676f0455d4be5ae672a97a682334..de80a9f367aefbf92ee5584df1d61cecce4762e3 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -1786,6 +1786,8 @@ def CMDcomments(parser, args):
help='comment to add to an issue')
parser.add_option('-i', dest='issue',
help="review issue id (defaults to current issue)")
+ parser.add_option('-j', '--json-file',
+ help='File to write JSON summary to')
auth.add_auth_options(parser)
options, args = parser.parse_args(args)
auth_config = auth.extract_auth_config_from_options(options)
@@ -1804,11 +1806,21 @@ def CMDcomments(parser, args):
return 0
data = cl.GetIssueProperties()
+ summary = []
for message in sorted(data.get('messages', []), key=lambda x: x['date']):
+ summary.append({
+ 'date': message['date'],
+ 'lgtm': False,
+ 'message': message['text'],
+ 'not_lgtm': False,
+ 'sender': message['sender'],
+ })
if message['disapproval']:
color = Fore.RED
+ summary[-1]['not lgtm'] = True
elif message['approval']:
color = Fore.GREEN
+ summary[-1]['lgtm'] = True
elif message['sender'] == data['owner_email']:
color = Fore.MAGENTA
else:
@@ -1818,6 +1830,9 @@ def CMDcomments(parser, args):
Fore.RESET)
if message['text'].strip():
print '\n'.join(' ' + l for l in message['text'].splitlines())
+ if options.json_file:
+ with open(options.json_file, 'wb') as f:
+ json.dump(summary, f)
return 0
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698