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

Side by Side Diff: git_cl.py

Issue 20888002: Disable colors if not a tty. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Update references to 'git cl' in git cl smoke tests to $GIT_CL. Created 7 years, 4 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 | tests/basic.sh » ('j') | 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 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 url = c.GetIssueURL() 1162 url = c.GetIssueURL()
1163 output.put((b, url, Fore.BLUE if url else Fore.WHITE)) 1163 output.put((b, url, Fore.BLUE if url else Fore.WHITE))
1164 1164
1165 tmp = {} 1165 tmp = {}
1166 alignment = max(5, max(len(ShortBranchName(b)) for b in branches)) 1166 alignment = max(5, max(len(ShortBranchName(b)) for b in branches))
1167 for branch in sorted(branches): 1167 for branch in sorted(branches):
1168 while branch not in tmp: 1168 while branch not in tmp:
1169 b, i, color = output.get() 1169 b, i, color = output.get()
1170 tmp[b] = (i, color) 1170 tmp[b] = (i, color)
1171 issue, color = tmp.pop(branch) 1171 issue, color = tmp.pop(branch)
1172 reset = Fore.RESET
1173 if not sys.stdout.isatty():
1174 color = ''
1175 reset = ''
1172 print ' %*s: %s%s%s' % ( 1176 print ' %*s: %s%s%s' % (
1173 alignment, ShortBranchName(branch), color, issue, Fore.RESET) 1177 alignment, ShortBranchName(branch), color, issue, reset)
1174 1178
1175 cl = Changelist() 1179 cl = Changelist()
1176 print 1180 print
1177 print 'Current branch:', 1181 print 'Current branch:',
1178 if not cl.GetIssue(): 1182 if not cl.GetIssue():
1179 print 'no issue assigned.' 1183 print 'no issue assigned.'
1180 return 0 1184 return 0
1181 print cl.GetBranch() 1185 print cl.GetBranch()
1182 print 'Issue number: %s (%s)' % (cl.GetIssue(), cl.GetIssueURL()) 1186 print 'Issue number: %s (%s)' % (cl.GetIssue(), cl.GetIssueURL())
1183 print 'Issue description:' 1187 print 'Issue description:'
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 GenUsage(parser, 'help') 2269 GenUsage(parser, 'help')
2266 return CMDhelp(parser, argv) 2270 return CMDhelp(parser, argv)
2267 2271
2268 2272
2269 if __name__ == '__main__': 2273 if __name__ == '__main__':
2270 # These affect sys.stdout so do it outside of main() to simplify mocks in 2274 # These affect sys.stdout so do it outside of main() to simplify mocks in
2271 # unit testing. 2275 # unit testing.
2272 fix_encoding.fix_encoding() 2276 fix_encoding.fix_encoding()
2273 colorama.init() 2277 colorama.init()
2274 sys.exit(main(sys.argv[1:])) 2278 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | tests/basic.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698