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

Side by Side Diff: git_cl.py

Issue 17379008: Make git cl status spit out URLs instead of just Rietveld issue numbers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 7 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 difflib 10 import difflib
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 # with that branch. 598 # with that branch.
599 if self.GetIssue(): 599 if self.GetIssue():
600 self.rietveld_server = gclient_utils.UpgradeToHttps(RunGit( 600 self.rietveld_server = gclient_utils.UpgradeToHttps(RunGit(
601 ['config', self._RietveldServer()], error_ok=True).strip()) 601 ['config', self._RietveldServer()], error_ok=True).strip())
602 if not self.rietveld_server: 602 if not self.rietveld_server:
603 self.rietveld_server = settings.GetDefaultServerUrl() 603 self.rietveld_server = settings.GetDefaultServerUrl()
604 return self.rietveld_server 604 return self.rietveld_server
605 605
606 def GetIssueURL(self): 606 def GetIssueURL(self):
607 """Get the URL for a particular issue.""" 607 """Get the URL for a particular issue."""
608 if not self.GetIssue():
609 return None
608 return '%s/%s' % (self.GetRietveldServer(), self.GetIssue()) 610 return '%s/%s' % (self.GetRietveldServer(), self.GetIssue())
609 611
610 def GetDescription(self, pretty=False): 612 def GetDescription(self, pretty=False):
611 if not self.has_description: 613 if not self.has_description:
612 if self.GetIssue(): 614 if self.GetIssue():
613 issue = self.GetIssue() 615 issue = self.GetIssue()
614 try: 616 try:
615 self.description = self.RpcServer().get_description(issue).strip() 617 self.description = self.RpcServer().get_description(issue).strip()
616 except urllib2.HTTPError, e: 618 except urllib2.HTTPError, e:
617 if e.code == 404: 619 if e.code == 404:
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 parser.add_option('--field', 1042 parser.add_option('--field',
1041 help='print only specific field (desc|id|patch|url)') 1043 help='print only specific field (desc|id|patch|url)')
1042 (options, args) = parser.parse_args(args) 1044 (options, args) = parser.parse_args(args)
1043 1045
1044 # TODO: maybe make show_branches a flag if necessary. 1046 # TODO: maybe make show_branches a flag if necessary.
1045 show_branches = not options.field 1047 show_branches = not options.field
1046 1048
1047 if show_branches: 1049 if show_branches:
1048 branches = RunGit(['for-each-ref', '--format=%(refname)', 'refs/heads']) 1050 branches = RunGit(['for-each-ref', '--format=%(refname)', 'refs/heads'])
1049 if branches: 1051 if branches:
1052 changes = (Changelist(branchref=b) for b in branches.splitlines())
1053 branches = dict((cl.GetBranch(), cl.GetIssueURL()) for cl in changes)
1054 alignment = max(5, max(len(b) for b in branches))
1050 print 'Branches associated with reviews:' 1055 print 'Branches associated with reviews:'
1051 changes = (Changelist(branchref=b) for b in branches.splitlines())
1052 branches = dict((cl.GetBranch(), cl.GetIssue()) for cl in changes)
1053 alignment = max(5, max(len(b) for b in branches))
1054 for branch in sorted(branches): 1056 for branch in sorted(branches):
1055 print " %*s: %s" % (alignment, branch, branches[branch]) 1057 print " %*s: %s" % (alignment, branch, branches[branch] or '')
1056 1058
1057 cl = Changelist() 1059 cl = Changelist()
1058 if options.field: 1060 if options.field:
1059 if options.field.startswith('desc'): 1061 if options.field.startswith('desc'):
1060 print cl.GetDescription() 1062 print cl.GetDescription()
1061 elif options.field == 'id': 1063 elif options.field == 'id':
1062 issueid = cl.GetIssue() 1064 issueid = cl.GetIssue()
1063 if issueid: 1065 if issueid:
1064 print issueid 1066 print issueid
1065 elif options.field == 'patch': 1067 elif options.field == 'patch':
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 GenUsage(parser, 'help') 2142 GenUsage(parser, 'help')
2141 return CMDhelp(parser, argv) 2143 return CMDhelp(parser, argv)
2142 2144
2143 2145
2144 if __name__ == '__main__': 2146 if __name__ == '__main__':
2145 # These affect sys.stdout so do it outside of main() to simplify mocks in 2147 # These affect sys.stdout so do it outside of main() to simplify mocks in
2146 # unit testing. 2148 # unit testing.
2147 fix_encoding.fix_encoding() 2149 fix_encoding.fix_encoding()
2148 colorama.init() 2150 colorama.init()
2149 sys.exit(main(sys.argv[1:])) 2151 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