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

Unified 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 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 c1ae3f7f1f1dfb16ccd82cb12daada1e1bd3c86b..db9823042e62a91a1e8258e007cc5a90380c162b 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -1066,21 +1066,8 @@ def CMDstatus(parser, args):
help='print only specific field (desc|id|patch|url)')
(options, args) = parser.parse_args(args)
- # TODO: maybe make show_branches a flag if necessary.
- show_branches = not options.field
-
- if show_branches:
- branches = RunGit(['for-each-ref', '--format=%(refname)', 'refs/heads'])
- if branches:
- changes = (Changelist(branchref=b) for b in branches.splitlines())
- branches = dict((cl.GetBranch(), cl.GetIssueURL()) for cl in changes)
- alignment = max(5, max(len(b) for b in branches))
- print 'Branches associated with reviews:'
- for branch in sorted(branches):
- print " %*s: %s" % (alignment, branch, branches[branch])
-
- cl = Changelist()
if options.field:
+ cl = Changelist()
if options.field.startswith('desc'):
print cl.GetDescription()
elif options.field == 'id':
@@ -1095,16 +1082,29 @@ def CMDstatus(parser, args):
url = cl.GetIssueURL()
if url:
print url
- else:
- print
- print 'Current branch:',
- if not cl.GetIssue():
- print 'no issue assigned.'
- return 0
- print cl.GetBranch()
- print 'Issue number: %s (%s)' % (cl.GetIssue(), cl.GetIssueURL())
- print 'Issue description:'
- print cl.GetDescription(pretty=True)
+ return 0
+
+ branches = RunGit(['for-each-ref', '--format=%(refname)', 'refs/heads'])
+ if not branches:
+ print('No local branch found.')
+ return 0
+
+ changes = (Changelist(branchref=b) for b in branches.splitlines())
+ branches = dict((c.GetBranch(), c.GetIssueURL()) for c in changes)
+ alignment = max(5, max(len(b) for b in branches))
+ print 'Branches associated with reviews:'
+ for branch in sorted(branches):
+ print " %*s: %s" % (alignment, branch, branches[branch])
+ cl = Changelist()
+ print
+ print 'Current branch:',
+ if not cl.GetIssue():
+ print 'no issue assigned.'
+ return 0
+ print cl.GetBranch()
+ print 'Issue number: %s (%s)' % (cl.GetIssue(), cl.GetIssueURL())
+ print 'Issue description:'
+ print cl.GetDescription(pretty=True)
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