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

Side by Side Diff: git_cl.py

Issue 19463011: Cleanup 'git cl status' in preparation to add new features. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: trying harder Created 7 years, 5 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 difflib 10 import difflib
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 return RunGit(['config', 'branch.%s.base-url' % branch, args[0]], 1059 return RunGit(['config', 'branch.%s.base-url' % branch, args[0]],
1060 error_ok=False).strip() 1060 error_ok=False).strip()
1061 1061
1062 1062
1063 def CMDstatus(parser, args): 1063 def CMDstatus(parser, args):
1064 """show status of changelists""" 1064 """show status of changelists"""
1065 parser.add_option('--field', 1065 parser.add_option('--field',
1066 help='print only specific field (desc|id|patch|url)') 1066 help='print only specific field (desc|id|patch|url)')
1067 (options, args) = parser.parse_args(args) 1067 (options, args) = parser.parse_args(args)
1068 1068
1069 # TODO: maybe make show_branches a flag if necessary.
1070 show_branches = not options.field
1071
1072 if show_branches:
1073 branches = RunGit(['for-each-ref', '--format=%(refname)', 'refs/heads'])
1074 if branches:
1075 changes = (Changelist(branchref=b) for b in branches.splitlines())
1076 branches = dict((cl.GetBranch(), cl.GetIssueURL()) for cl in changes)
1077 alignment = max(5, max(len(b) for b in branches))
1078 print 'Branches associated with reviews:'
1079 for branch in sorted(branches):
1080 print " %*s: %s" % (alignment, branch, branches[branch])
1081
1082 cl = Changelist()
1083 if options.field: 1069 if options.field:
1070 cl = Changelist()
1084 if options.field.startswith('desc'): 1071 if options.field.startswith('desc'):
1085 print cl.GetDescription() 1072 print cl.GetDescription()
1086 elif options.field == 'id': 1073 elif options.field == 'id':
1087 issueid = cl.GetIssue() 1074 issueid = cl.GetIssue()
1088 if issueid: 1075 if issueid:
1089 print issueid 1076 print issueid
1090 elif options.field == 'patch': 1077 elif options.field == 'patch':
1091 patchset = cl.GetPatchset() 1078 patchset = cl.GetPatchset()
1092 if patchset: 1079 if patchset:
1093 print patchset 1080 print patchset
1094 elif options.field == 'url': 1081 elif options.field == 'url':
1095 url = cl.GetIssueURL() 1082 url = cl.GetIssueURL()
1096 if url: 1083 if url:
1097 print url 1084 print url
1098 else: 1085 return 0
1099 print 1086
1100 print 'Current branch:', 1087 branches = RunGit(['for-each-ref', '--format=%(refname)', 'refs/heads'])
1101 if not cl.GetIssue(): 1088 if not branches:
1102 print 'no issue assigned.' 1089 print('No local branch found.')
1103 return 0 1090 return 0
1104 print cl.GetBranch() 1091
1105 print 'Issue number: %s (%s)' % (cl.GetIssue(), cl.GetIssueURL()) 1092 changes = (Changelist(branchref=b) for b in branches.splitlines())
1106 print 'Issue description:' 1093 branches = dict((c.GetBranch(), c.GetIssueURL()) for c in changes)
1107 print cl.GetDescription(pretty=True) 1094 alignment = max(5, max(len(b) for b in branches))
1095 print 'Branches associated with reviews:'
1096 for branch in sorted(branches):
1097 print " %*s: %s" % (alignment, branch, branches[branch])
1098 cl = Changelist()
1099 print
1100 print 'Current branch:',
1101 if not cl.GetIssue():
1102 print 'no issue assigned.'
1103 return 0
1104 print cl.GetBranch()
1105 print 'Issue number: %s (%s)' % (cl.GetIssue(), cl.GetIssueURL())
1106 print 'Issue description:'
1107 print cl.GetDescription(pretty=True)
1108 return 0 1108 return 0
1109 1109
1110 1110
1111 @usage('[issue_number]') 1111 @usage('[issue_number]')
1112 def CMDissue(parser, args): 1112 def CMDissue(parser, args):
1113 """Set or display the current code review issue number. 1113 """Set or display the current code review issue number.
1114 1114
1115 Pass issue number 0 to clear the current issue. 1115 Pass issue number 0 to clear the current issue.
1116 """ 1116 """
1117 _, args = parser.parse_args(args) 1117 _, args = parser.parse_args(args)
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
2177 GenUsage(parser, 'help') 2177 GenUsage(parser, 'help')
2178 return CMDhelp(parser, argv) 2178 return CMDhelp(parser, argv)
2179 2179
2180 2180
2181 if __name__ == '__main__': 2181 if __name__ == '__main__':
2182 # These affect sys.stdout so do it outside of main() to simplify mocks in 2182 # These affect sys.stdout so do it outside of main() to simplify mocks in
2183 # unit testing. 2183 # unit testing.
2184 fix_encoding.fix_encoding() 2184 fix_encoding.fix_encoding()
2185 colorama.init() 2185 colorama.init()
2186 sys.exit(main(sys.argv[1:])) 2186 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