OLD | NEW |
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 """Enables directory-specific presubmit checks to run at upload and/or commit. | 6 """Enables directory-specific presubmit checks to run at upload and/or commit. |
7 """ | 7 """ |
8 | 8 |
9 __version__ = '1.6.2' | 9 __version__ = '1.6.2' |
10 | 10 |
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 "system directories will also be searched.") | 1325 "system directories will also be searched.") |
1326 parser.add_option("--default_presubmit") | 1326 parser.add_option("--default_presubmit") |
1327 parser.add_option("--may_prompt", action='store_true', default=False) | 1327 parser.add_option("--may_prompt", action='store_true', default=False) |
1328 parser.add_option("--skip_canned", action='append', default=[], | 1328 parser.add_option("--skip_canned", action='append', default=[], |
1329 help="A list of checks to skip which appear in " | 1329 help="A list of checks to skip which appear in " |
1330 "presubmit_canned_checks. Can be provided multiple times " | 1330 "presubmit_canned_checks. Can be provided multiple times " |
1331 "to skip multiple canned checks.") | 1331 "to skip multiple canned checks.") |
1332 parser.add_option("--rietveld_url", help=optparse.SUPPRESS_HELP) | 1332 parser.add_option("--rietveld_url", help=optparse.SUPPRESS_HELP) |
1333 parser.add_option("--rietveld_email", help=optparse.SUPPRESS_HELP) | 1333 parser.add_option("--rietveld_email", help=optparse.SUPPRESS_HELP) |
1334 parser.add_option("--rietveld_password", help=optparse.SUPPRESS_HELP) | 1334 parser.add_option("--rietveld_password", help=optparse.SUPPRESS_HELP) |
| 1335 parser.add_option("--rietveld_fetch", action='store_true', default=False, |
| 1336 help=optparse.SUPPRESS_HELP) |
1335 options, args = parser.parse_args(argv) | 1337 options, args = parser.parse_args(argv) |
1336 if options.verbose >= 2: | 1338 if options.verbose >= 2: |
1337 logging.basicConfig(level=logging.DEBUG) | 1339 logging.basicConfig(level=logging.DEBUG) |
1338 elif options.verbose: | 1340 elif options.verbose: |
1339 logging.basicConfig(level=logging.INFO) | 1341 logging.basicConfig(level=logging.INFO) |
1340 else: | 1342 else: |
1341 logging.basicConfig(level=logging.ERROR) | 1343 logging.basicConfig(level=logging.ERROR) |
1342 change_class, files = load_files(options, args) | 1344 change_class, files = load_files(options, args) |
1343 if not change_class: | 1345 if not change_class: |
1344 parser.error('For unversioned directory, <files> is not optional.') | 1346 parser.error('For unversioned directory, <files> is not optional.') |
1345 logging.info('Found %d file(s).' % len(files)) | 1347 logging.info('Found %d file(s).' % len(files)) |
1346 rietveld_obj = None | 1348 rietveld_obj = None |
1347 if options.rietveld_url: | 1349 if options.rietveld_url: |
1348 rietveld_obj = rietveld.CachingRietveld( | 1350 rietveld_obj = rietveld.CachingRietveld( |
1349 options.rietveld_url, | 1351 options.rietveld_url, |
1350 options.rietveld_email, | 1352 options.rietveld_email, |
1351 options.rietveld_password) | 1353 options.rietveld_password) |
| 1354 if options.rietveld_fetch: |
| 1355 assert options.issue |
| 1356 props = rietveld_obj.get_issue_properties(options.issue, False) |
| 1357 options.author = props['owner_email'] |
| 1358 options.description = props['description'] |
| 1359 logging.info('Got author: "%s"', options.author) |
| 1360 logging.info('Got description: """\n%s\n"""', options.description) |
1352 try: | 1361 try: |
1353 with canned_check_filter(options.skip_canned): | 1362 with canned_check_filter(options.skip_canned): |
1354 results = DoPresubmitChecks( | 1363 results = DoPresubmitChecks( |
1355 change_class(options.name, | 1364 change_class(options.name, |
1356 options.description, | 1365 options.description, |
1357 options.root, | 1366 options.root, |
1358 files, | 1367 files, |
1359 options.issue, | 1368 options.issue, |
1360 options.patchset, | 1369 options.patchset, |
1361 options.author), | 1370 options.author), |
(...skipping 12 matching lines...) Expand all Loading... |
1374 except PresubmitFailure, e: | 1383 except PresubmitFailure, e: |
1375 print >> sys.stderr, e | 1384 print >> sys.stderr, e |
1376 print >> sys.stderr, 'Maybe your depot_tools is out of date?' | 1385 print >> sys.stderr, 'Maybe your depot_tools is out of date?' |
1377 print >> sys.stderr, 'If all fails, contact maruel@' | 1386 print >> sys.stderr, 'If all fails, contact maruel@' |
1378 return 2 | 1387 return 2 |
1379 | 1388 |
1380 | 1389 |
1381 if __name__ == '__main__': | 1390 if __name__ == '__main__': |
1382 fix_encoding.fix_encoding() | 1391 fix_encoding.fix_encoding() |
1383 sys.exit(Main(None)) | 1392 sys.exit(Main(None)) |
OLD | NEW |