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

Side by Side Diff: git_number.py

Issue 534703002: Require 'CHROME_HEADLESS' to use 'git-number'. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Updated environment check. Created 6 years, 3 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 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 """Usage: %prog [options] [<commitref>]* 6 """Usage: %prog [options] [<commitref>]*
7 7
8 If no <commitref>'s are supplied, it defaults to HEAD. 8 If no <commitref>'s are supplied, it defaults to HEAD.
9 9
10 Calculates the generation number for one or more commits in a git repo. 10 Calculates the generation number for one or more commits in a git repo.
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 help='Do not actually cache anything we calculate.') 245 help='Do not actually cache anything we calculate.')
246 parser.add_option('--reset', action='store_true', 246 parser.add_option('--reset', action='store_true',
247 help='Reset the generation number cache and quit.') 247 help='Reset the generation number cache and quit.')
248 parser.add_option('-v', '--verbose', action='count', default=0, 248 parser.add_option('-v', '--verbose', action='count', default=0,
249 help='Be verbose. Use more times for more verbosity.') 249 help='Be verbose. Use more times for more verbosity.')
250 opts, args = parser.parse_args() 250 opts, args = parser.parse_args()
251 251
252 levels = [logging.ERROR, logging.INFO, logging.DEBUG] 252 levels = [logging.ERROR, logging.INFO, logging.DEBUG]
253 logging.basicConfig(level=levels[min(opts.verbose, len(levels) - 1)]) 253 logging.basicConfig(level=levels[min(opts.verbose, len(levels) - 1)])
254 254
255 # 'git number' should only be used on bots.
256 if os.getenv('CHROME_HEADLESS') != '1':
257 logging.error("'git-number' is an infrastructure tool that is only "
258 "intended to be used internally by bots. Developers should "
259 "use the 'Cr-Commit-Position' value in the commit's message.")
260 return 1
261
255 try: 262 try:
256 if opts.reset: 263 if opts.reset:
257 clear_caches(on_disk=True) 264 clear_caches(on_disk=True)
258 return 265 return
259 266
260 try: 267 try:
261 targets = git.parse_commitrefs(*(args or ['HEAD'])) 268 targets = git.parse_commitrefs(*(args or ['HEAD']))
262 except git.BadCommitRefException as e: 269 except git.BadCommitRefException as e:
263 parser.error(e) 270 parser.error(e)
264 271
265 load_generation_numbers(targets) 272 load_generation_numbers(targets)
266 if not opts.no_cache: 273 if not opts.no_cache:
267 finalize(targets) 274 finalize(targets)
268 275
269 print '\n'.join(map(str, map(get_num, targets))) 276 print '\n'.join(map(str, map(get_num, targets)))
270 return 0 277 return 0
271 except KeyboardInterrupt: 278 except KeyboardInterrupt:
272 return 1 279 return 1
273 280
274 281
275 if __name__ == '__main__': # pragma: no cover 282 if __name__ == '__main__': # pragma: no cover
276 sys.exit(main()) 283 sys.exit(main())
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