| 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.8.0' | 9 __version__ = '1.8.0' |
| 10 | 10 |
| (...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 change_scm = scm.determine_scm(options.root) | 1451 change_scm = scm.determine_scm(options.root) |
| 1452 files = [] | 1452 files = [] |
| 1453 if args: | 1453 if args: |
| 1454 files = ParseFiles(args, options.recursive) | 1454 files = ParseFiles(args, options.recursive) |
| 1455 if change_scm == 'svn': | 1455 if change_scm == 'svn': |
| 1456 change_class = SvnChange | 1456 change_class = SvnChange |
| 1457 if not files: | 1457 if not files: |
| 1458 files = scm.SVN.CaptureStatus([], options.root) | 1458 files = scm.SVN.CaptureStatus([], options.root) |
| 1459 elif change_scm == 'git': | 1459 elif change_scm == 'git': |
| 1460 change_class = GitChange | 1460 change_class = GitChange |
| 1461 # TODO(maruel): Get upstream. | 1461 upstream = options.upstream or None |
| 1462 if not files: | 1462 if not files: |
| 1463 files = scm.GIT.CaptureStatus([], options.root, None) | 1463 files = scm.GIT.CaptureStatus([], options.root, upstream) |
| 1464 else: | 1464 else: |
| 1465 logging.info('Doesn\'t seem under source control. Got %d files' % len(args)) | 1465 logging.info('Doesn\'t seem under source control. Got %d files' % len(args)) |
| 1466 if not files: | 1466 if not files: |
| 1467 return None, None | 1467 return None, None |
| 1468 change_class = Change | 1468 change_class = Change |
| 1469 return change_class, files | 1469 return change_class, files |
| 1470 | 1470 |
| 1471 | 1471 |
| 1472 class NonexistantCannedCheckFilter(Exception): | 1472 class NonexistantCannedCheckFilter(Exception): |
| 1473 pass | 1473 pass |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 parser.add_option("--name", default='no name') | 1525 parser.add_option("--name", default='no name') |
| 1526 parser.add_option("--author") | 1526 parser.add_option("--author") |
| 1527 parser.add_option("--description", default='') | 1527 parser.add_option("--description", default='') |
| 1528 parser.add_option("--issue", type='int', default=0) | 1528 parser.add_option("--issue", type='int', default=0) |
| 1529 parser.add_option("--patchset", type='int', default=0) | 1529 parser.add_option("--patchset", type='int', default=0) |
| 1530 parser.add_option("--root", default=os.getcwd(), | 1530 parser.add_option("--root", default=os.getcwd(), |
| 1531 help="Search for PRESUBMIT.py up to this directory. " | 1531 help="Search for PRESUBMIT.py up to this directory. " |
| 1532 "If inherit-review-settings-ok is present in this " | 1532 "If inherit-review-settings-ok is present in this " |
| 1533 "directory, parent directories up to the root file " | 1533 "directory, parent directories up to the root file " |
| 1534 "system directories will also be searched.") | 1534 "system directories will also be searched.") |
| 1535 parser.add_option("--upstream", |
| 1536 help="Git only: the base ref or upstream branch against " |
| 1537 "which the diff should be computed.") |
| 1535 parser.add_option("--default_presubmit") | 1538 parser.add_option("--default_presubmit") |
| 1536 parser.add_option("--may_prompt", action='store_true', default=False) | 1539 parser.add_option("--may_prompt", action='store_true', default=False) |
| 1537 parser.add_option("--skip_canned", action='append', default=[], | 1540 parser.add_option("--skip_canned", action='append', default=[], |
| 1538 help="A list of checks to skip which appear in " | 1541 help="A list of checks to skip which appear in " |
| 1539 "presubmit_canned_checks. Can be provided multiple times " | 1542 "presubmit_canned_checks. Can be provided multiple times " |
| 1540 "to skip multiple canned checks.") | 1543 "to skip multiple canned checks.") |
| 1541 parser.add_option("--rietveld_url", help=optparse.SUPPRESS_HELP) | 1544 parser.add_option("--rietveld_url", help=optparse.SUPPRESS_HELP) |
| 1542 parser.add_option("--rietveld_email", help=optparse.SUPPRESS_HELP) | 1545 parser.add_option("--rietveld_email", help=optparse.SUPPRESS_HELP) |
| 1543 parser.add_option("--rietveld_password", help=optparse.SUPPRESS_HELP) | 1546 parser.add_option("--rietveld_password", help=optparse.SUPPRESS_HELP) |
| 1544 parser.add_option("--rietveld_fetch", action='store_true', default=False, | 1547 parser.add_option("--rietveld_fetch", action='store_true', default=False, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 except PresubmitFailure, e: | 1647 except PresubmitFailure, e: |
| 1645 print >> sys.stderr, e | 1648 print >> sys.stderr, e |
| 1646 print >> sys.stderr, 'Maybe your depot_tools is out of date?' | 1649 print >> sys.stderr, 'Maybe your depot_tools is out of date?' |
| 1647 print >> sys.stderr, 'If all fails, contact maruel@' | 1650 print >> sys.stderr, 'If all fails, contact maruel@' |
| 1648 return 2 | 1651 return 2 |
| 1649 | 1652 |
| 1650 | 1653 |
| 1651 if __name__ == '__main__': | 1654 if __name__ == '__main__': |
| 1652 fix_encoding.fix_encoding() | 1655 fix_encoding.fix_encoding() |
| 1653 sys.exit(Main(None)) | 1656 sys.exit(Main(None)) |
| OLD | NEW |