Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Generic presubmit checks that can be reused by other presubmit checks.""" | 5 """Generic presubmit checks that can be reused by other presubmit checks.""" |
| 6 | 6 |
| 7 import os as _os | 7 import os as _os |
| 8 _HERE = _os.path.dirname(_os.path.abspath(__file__)) | 8 _HERE = _os.path.dirname(_os.path.abspath(__file__)) |
| 9 | 9 |
| 10 | 10 |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 636 extra_paths_list = extra_paths_list or [] | 636 extra_paths_list = extra_paths_list or [] |
| 637 | 637 |
| 638 if input_api.is_committing: | 638 if input_api.is_committing: |
| 639 error_type = output_api.PresubmitError | 639 error_type = output_api.PresubmitError |
| 640 else: | 640 else: |
| 641 error_type = output_api.PresubmitPromptWarning | 641 error_type = output_api.PresubmitPromptWarning |
| 642 | 642 |
| 643 # Only trigger if there is at least one python file affected. | 643 # Only trigger if there is at least one python file affected. |
| 644 def rel_path(regex): | 644 def rel_path(regex): |
| 645 """Modifies a regex for a subject to accept paths relative to root.""" | 645 """Modifies a regex for a subject to accept paths relative to root.""" |
| 646 if input_api.os_path.samefile( | 646 if hasattr(input_api.os_path, 'samefile'): |
|
M-A Ruel
2013/01/18 16:31:46
Actually, it could be written shorter with:
def s
chrisha
2013/01/18 16:52:12
And this is where it shows that I'm not really a P
| |
| 647 input_api.PresubmitLocalPath(), input_api.change.RepositoryRoot()): | 647 if input_api.os_path.samefile(input_api.PresubmitLocalPath(), |
| 648 return regex | 648 input_api.change.RepositoryRoot()): |
| 649 return regex | |
| 650 else: | |
| 651 # 'samefile' doesn't exist on Windows, so we fall back to an exact | |
| 652 # path match. | |
| 653 if (input_api.os_path.abspath(input_api.PresubmitLocalPath()) == | |
| 654 input_api.os_path.abspath(input_api.change.RepositoryRoot())): | |
| 655 return regex | |
| 649 prefix = input_api.os_path.join(input_api.os_path.relpath( | 656 prefix = input_api.os_path.join(input_api.os_path.relpath( |
| 650 input_api.PresubmitLocalPath(), input_api.change.RepositoryRoot()), '') | 657 input_api.PresubmitLocalPath(), input_api.change.RepositoryRoot()), '') |
| 651 return input_api.re.escape(prefix) + regex | 658 return input_api.re.escape(prefix) + regex |
| 652 src_filter = lambda x: input_api.FilterSourceFile( | 659 src_filter = lambda x: input_api.FilterSourceFile( |
| 653 x, map(rel_path, white_list), map(rel_path, black_list)) | 660 x, map(rel_path, white_list), map(rel_path, black_list)) |
| 654 if not input_api.AffectedSourceFiles(src_filter): | 661 if not input_api.AffectedSourceFiles(src_filter): |
| 655 input_api.logging.info('Skipping pylint: no matching changes.') | 662 input_api.logging.info('Skipping pylint: no matching changes.') |
| 656 return [] | 663 return [] |
| 657 | 664 |
| 658 extra_args = ['--rcfile=%s' % input_api.os_path.join(_HERE, 'pylintrc')] | 665 extra_args = ['--rcfile=%s' % input_api.os_path.join(_HERE, 'pylintrc')] |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 999 snapshot("checking description") | 1006 snapshot("checking description") |
| 1000 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 1007 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
| 1001 input_api, output_api)) | 1008 input_api, output_api)) |
| 1002 results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription( | 1009 results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription( |
| 1003 input_api, output_api)) | 1010 input_api, output_api)) |
| 1004 snapshot("checking do not submit in files") | 1011 snapshot("checking do not submit in files") |
| 1005 results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( | 1012 results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( |
| 1006 input_api, output_api)) | 1013 input_api, output_api)) |
| 1007 snapshot("done") | 1014 snapshot("done") |
| 1008 return results | 1015 return results |
| OLD | NEW |