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

Side by Side Diff: git_cl.py

Issue 10540035: Add git cl comments to read rietveld comments without having to use the rietveld UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: The messages list may be out of order so we need to reorder it Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # Copyright (C) 2008 Evan Martin <martine@danga.com> 6 # Copyright (C) 2008 Evan Martin <martine@danga.com>
7 7
8 """A git-command for integrating reviews on Rietveld.""" 8 """A git-command for integrating reviews on Rietveld."""
9 9
10 import json 10 import json
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 try: 861 try:
862 issue = int(args[0]) 862 issue = int(args[0])
863 except ValueError: 863 except ValueError:
864 DieWithError('Pass a number to set the issue or none to list it.\n' 864 DieWithError('Pass a number to set the issue or none to list it.\n'
865 'Maybe you want to run git cl status?') 865 'Maybe you want to run git cl status?')
866 cl.SetIssue(issue) 866 cl.SetIssue(issue)
867 print 'Issue number:', cl.GetIssue(), '(%s)' % cl.GetIssueURL() 867 print 'Issue number:', cl.GetIssue(), '(%s)' % cl.GetIssueURL()
868 return 0 868 return 0
869 869
870 870
871 def CMDcomments(parser, args):
872 """show review comments of the current changelist"""
873 (_, args) = parser.parse_args(args)
874 if args:
875 parser.error('Unsupported argument: %s' % args)
876
877 cl = Changelist()
878 if cl.GetIssue():
879 data = cl.RpcServer().get_issue_properties(cl.GetIssue(), True)
880 for message in sorted(data['messages'], key=lambda x: x['date']):
881 print '\n%s %s' % (message['date'].split('.', 1)[0], message['sender'])
882 if message['text'].strip():
883 print '\n'.join(' ' + l for l in message['text'].splitlines())
884 return 0
885
886
871 def CreateDescriptionFromLog(args): 887 def CreateDescriptionFromLog(args):
872 """Pulls out the commit log to use as a base for the CL description.""" 888 """Pulls out the commit log to use as a base for the CL description."""
873 log_args = [] 889 log_args = []
874 if len(args) == 1 and not args[0].endswith('.'): 890 if len(args) == 1 and not args[0].endswith('.'):
875 log_args = [args[0] + '..'] 891 log_args = [args[0] + '..']
876 elif len(args) == 1 and args[0].endswith('...'): 892 elif len(args) == 1 and args[0].endswith('...'):
877 log_args = [args[0][:-1]] 893 log_args = [args[0][:-1]]
878 elif len(args) == 2: 894 elif len(args) == 2:
879 log_args = [args[0] + '..' + args[1]] 895 log_args = [args[0] + '..' + args[1]]
880 else: 896 else:
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 help='target branch to upload') 1091 help='target branch to upload')
1076 (options, args) = parser.parse_args(args) 1092 (options, args) = parser.parse_args(args)
1077 1093
1078 # Print warning if the user used the -m/--message argument. This will soon 1094 # Print warning if the user used the -m/--message argument. This will soon
1079 # change to -t/--title. 1095 # change to -t/--title.
1080 if options.message: 1096 if options.message:
1081 print >> sys.stderr, ( 1097 print >> sys.stderr, (
1082 '\nWARNING: Use -t or --title to set the title of the patchset.\n' 1098 '\nWARNING: Use -t or --title to set the title of the patchset.\n'
1083 'In the near future, -m or --message will send a message instead.\n' 1099 'In the near future, -m or --message will send a message instead.\n'
1084 'See http://goo.gl/JGg0Z for details.\n') 1100 'See http://goo.gl/JGg0Z for details.\n')
1085 1101
1086 # Make sure index is up-to-date before running diff-index. 1102 # Make sure index is up-to-date before running diff-index.
1087 RunGit(['update-index', '--refresh', '-q'], error_ok=True) 1103 RunGit(['update-index', '--refresh', '-q'], error_ok=True)
1088 if RunGit(['diff-index', 'HEAD']): 1104 if RunGit(['diff-index', 'HEAD']):
1089 print 'Cannot upload with a dirty tree. You must commit locally first.' 1105 print 'Cannot upload with a dirty tree. You must commit locally first.'
1090 return 1 1106 return 1
1091 1107
1092 cl = Changelist() 1108 cl = Changelist()
1093 if args: 1109 if args:
1094 # TODO(ukai): is it ok for gerrit case? 1110 # TODO(ukai): is it ok for gerrit case?
1095 base_branch = args[0] 1111 base_branch = args[0]
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 1570 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
1555 1571
1556 # Not a known command. Default to help. 1572 # Not a known command. Default to help.
1557 GenUsage(parser, 'help') 1573 GenUsage(parser, 'help')
1558 return CMDhelp(parser, argv) 1574 return CMDhelp(parser, argv)
1559 1575
1560 1576
1561 if __name__ == '__main__': 1577 if __name__ == '__main__':
1562 fix_encoding.fix_encoding() 1578 fix_encoding.fix_encoding()
1563 sys.exit(main(sys.argv[1:])) 1579 sys.exit(main(sys.argv[1:]))
OLDNEW
« 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