| 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 """Top-level presubmit script for Chromium. | 5 """Top-level presubmit script for Chromium. |
| 6 | 6 |
| 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 for more details about the presubmit API built into gcl. | 8 for more details about the presubmit API built into gcl. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 | 720 |
| 721 results = [] | 721 results = [] |
| 722 if errors: | 722 if errors: |
| 723 results.append(output_api.PresubmitError( | 723 results.append(output_api.PresubmitError( |
| 724 'The name of PNG files should not have abbreviations. \n' | 724 'The name of PNG files should not have abbreviations. \n' |
| 725 'Use _hover.png, _center.png, instead of _h.png, _c.png.\n' | 725 'Use _hover.png, _center.png, instead of _h.png, _c.png.\n' |
| 726 'Contact oshima@chromium.org if you have questions.', errors)) | 726 'Contact oshima@chromium.org if you have questions.', errors)) |
| 727 return results | 727 return results |
| 728 | 728 |
| 729 | 729 |
| 730 def _DepsFilesToCheck(re, changed_lines): |
| 731 """Helper method for _CheckAddedDepsHaveTargetApprovals. Returns |
| 732 a set of DEPS entries that we should look up.""" |
| 733 results = set() |
| 734 |
| 735 # This pattern grabs the path without basename in the first |
| 736 # parentheses, and the basename (if present) in the second. It |
| 737 # relies on the simple heuristic that if there is a basename it will |
| 738 # be a header file ending in ".h". |
| 739 pattern = re.compile( |
| 740 r"""['"]\+([^'"]+?)(/[a-zA-Z0-9_]+\.h)?['"].*""") |
| 741 for changed_line in changed_lines: |
| 742 m = pattern.match(changed_line) |
| 743 if m: |
| 744 path = m.group(1) |
| 745 if not (path.startswith('grit/') or path == 'grit'): |
| 746 results.add('%s/DEPS' % m.group(1)) |
| 747 return results |
| 748 |
| 749 |
| 730 def _CheckAddedDepsHaveTargetApprovals(input_api, output_api): | 750 def _CheckAddedDepsHaveTargetApprovals(input_api, output_api): |
| 731 """When a dependency prefixed with + is added to a DEPS file, we | 751 """When a dependency prefixed with + is added to a DEPS file, we |
| 732 want to make sure that the change is reviewed by an OWNER of the | 752 want to make sure that the change is reviewed by an OWNER of the |
| 733 target file or directory, to avoid layering violations from being | 753 target file or directory, to avoid layering violations from being |
| 734 introduced. This check verifies that this happens. | 754 introduced. This check verifies that this happens. |
| 735 """ | 755 """ |
| 736 changed_lines = set() | 756 changed_lines = set() |
| 737 for f in input_api.AffectedFiles(): | 757 for f in input_api.AffectedFiles(): |
| 738 filename = input_api.os_path.basename(f.LocalPath()) | 758 filename = input_api.os_path.basename(f.LocalPath()) |
| 739 if filename == 'DEPS': | 759 if filename == 'DEPS': |
| 740 changed_lines |= set(line.strip() | 760 changed_lines |= set(line.strip() |
| 741 for line_num, line | 761 for line_num, line |
| 742 in f.ChangedContents()) | 762 in f.ChangedContents()) |
| 743 if not changed_lines: | 763 if not changed_lines: |
| 744 return [] | 764 return [] |
| 745 | 765 |
| 746 virtual_depended_on_files = set() | 766 virtual_depended_on_files = _DepsFilesToCheck(input_api.re, changed_lines) |
| 747 # This pattern grabs the path without basename in the first | |
| 748 # parentheses, and the basename (if present) in the second. It | |
| 749 # relies on the simple heuristic that if there is a basename it will | |
| 750 # be a header file ending in ".h". | |
| 751 pattern = input_api.re.compile( | |
| 752 r"""['"]\+([^'"]+?)(/[a-zA-Z0-9_]+\.h)?['"].*""") | |
| 753 for changed_line in changed_lines: | |
| 754 m = pattern.match(changed_line) | |
| 755 if m: | |
| 756 path = m.group(1) | |
| 757 if not path.startswith('grit/'): | |
| 758 virtual_depended_on_files.add('%s/DEPS' % m.group(1)) | |
| 759 | |
| 760 if not virtual_depended_on_files: | 767 if not virtual_depended_on_files: |
| 761 return [] | 768 return [] |
| 762 | 769 |
| 763 if input_api.is_committing: | 770 if input_api.is_committing: |
| 764 if input_api.tbr: | 771 if input_api.tbr: |
| 765 return [output_api.PresubmitNotifyResult( | 772 return [output_api.PresubmitNotifyResult( |
| 766 '--tbr was specified, skipping OWNERS check for DEPS additions')] | 773 '--tbr was specified, skipping OWNERS check for DEPS additions')] |
| 767 if not input_api.change.issue: | 774 if not input_api.change.issue: |
| 768 return [output_api.PresubmitError( | 775 return [output_api.PresubmitError( |
| 769 "DEPS approval by OWNERS check failed: this change has " | 776 "DEPS approval by OWNERS check failed: this change has " |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 trybots += ['linux_chromeos_clang:compile', 'linux_chromeos_asan'] | 1047 trybots += ['linux_chromeos_clang:compile', 'linux_chromeos_asan'] |
| 1041 | 1048 |
| 1042 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it | 1049 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it |
| 1043 # unless they're .gyp(i) files as changes to those files can break the gyp | 1050 # unless they're .gyp(i) files as changes to those files can break the gyp |
| 1044 # step on that bot. | 1051 # step on that bot. |
| 1045 if (not all(re.search('^chrome', f) for f in files) or | 1052 if (not all(re.search('^chrome', f) for f in files) or |
| 1046 any(re.search('\.gypi?$', f) for f in files)): | 1053 any(re.search('\.gypi?$', f) for f in files)): |
| 1047 trybots += ['android_aosp'] | 1054 trybots += ['android_aosp'] |
| 1048 | 1055 |
| 1049 return trybots | 1056 return trybots |
| OLD | NEW |