| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 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 12 matching lines...) Expand all Loading... |
| 23 _LICENSE_HEADER = ( | 23 _LICENSE_HEADER = ( |
| 24 r".*? Copyright \(c\) 20[0-9\-]{2,7} The Chromium Authors\. All rights " | 24 r".*? Copyright \(c\) 20[0-9\-]{2,7} The Chromium Authors\. All rights " |
| 25 r"reserved\." "\n" | 25 r"reserved\." "\n" |
| 26 r".*? Use of this source code is governed by a BSD-style license that can " | 26 r".*? Use of this source code is governed by a BSD-style license that can " |
| 27 "be\n" | 27 "be\n" |
| 28 r".*? found in the LICENSE file\." | 28 r".*? found in the LICENSE file\." |
| 29 "\n" | 29 "\n" |
| 30 ) | 30 ) |
| 31 | 31 |
| 32 | 32 |
| 33 def _CheckConstNSObject(input_api, output_api, source_file_filter): |
| 34 """Checks to make sure no objective-c files have |const NSSomeClass*|.""" |
| 35 pattern = input_api.re.compile(r'const\s+NS\w*\s*\*') |
| 36 files = [] |
| 37 for f in input_api.AffectedSourceFiles(source_file_filter): |
| 38 if f.LocalPath().endswith('.h') or f.LocalPath().endswith('.mm'): |
| 39 contents = input_api.ReadFile(f) |
| 40 if pattern.search(contents): |
| 41 files.append(f) |
| 42 |
| 43 if len(files): |
| 44 if input_api.is_committing: |
| 45 res_type = output_api.PresubmitPromptWarning |
| 46 else: |
| 47 res_type = output_api.PresubmitNotifyResult |
| 48 return [ res_type('|const NSClass*| is wrong, see ' + |
| 49 'http://dev.chromium.org/developers/clang-mac', |
| 50 files) ] |
| 51 return [] |
| 52 |
| 53 |
| 33 def _CommonChecks(input_api, output_api): | 54 def _CommonChecks(input_api, output_api): |
| 34 results = [] | 55 results = [] |
| 35 # What does this code do? | 56 # What does this code do? |
| 36 # It loads the default black list (e.g. third_party, experimental, etc) and | 57 # It loads the default black list (e.g. third_party, experimental, etc) and |
| 37 # add our black list (breakpad, skia and v8 are still not following | 58 # add our black list (breakpad, skia and v8 are still not following |
| 38 # google style and are not really living this repository). | 59 # google style and are not really living this repository). |
| 39 # See presubmit_support.py InputApi.FilterSourceFile for the (simple) usage. | 60 # See presubmit_support.py InputApi.FilterSourceFile for the (simple) usage. |
| 40 black_list = input_api.DEFAULT_BLACK_LIST + _EXCLUDED_PATHS | 61 black_list = input_api.DEFAULT_BLACK_LIST + _EXCLUDED_PATHS |
| 41 white_list = input_api.DEFAULT_WHITE_LIST + _TEXT_FILES | 62 white_list = input_api.DEFAULT_WHITE_LIST + _TEXT_FILES |
| 42 sources = lambda x: input_api.FilterSourceFile(x, black_list=black_list) | 63 sources = lambda x: input_api.FilterSourceFile(x, black_list=black_list) |
| 43 text_files = lambda x: input_api.FilterSourceFile(x, black_list=black_list, | 64 text_files = lambda x: input_api.FilterSourceFile(x, black_list=black_list, |
| 44 white_list=white_list) | 65 white_list=white_list) |
| 45 results.extend(input_api.canned_checks.CheckLongLines( | 66 results.extend(input_api.canned_checks.CheckLongLines( |
| 46 input_api, output_api, source_file_filter=sources)) | 67 input_api, output_api, source_file_filter=sources)) |
| 47 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( | 68 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( |
| 48 input_api, output_api, source_file_filter=sources)) | 69 input_api, output_api, source_file_filter=sources)) |
| 49 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( | 70 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( |
| 50 input_api, output_api, source_file_filter=sources)) | 71 input_api, output_api, source_file_filter=sources)) |
| 51 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 72 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
| 52 input_api, output_api)) | 73 input_api, output_api)) |
| 53 results.extend(input_api.canned_checks.CheckChangeHasTestField( | 74 results.extend(input_api.canned_checks.CheckChangeHasTestField( |
| 54 input_api, output_api)) | 75 input_api, output_api)) |
| 55 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle( | 76 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle( |
| 56 input_api, output_api, source_file_filter=text_files)) | 77 input_api, output_api, source_file_filter=text_files)) |
| 57 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( | 78 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( |
| 58 input_api, output_api)) | 79 input_api, output_api)) |
| 59 results.extend(input_api.canned_checks.CheckLicense( | 80 results.extend(input_api.canned_checks.CheckLicense( |
| 60 input_api, output_api, _LICENSE_HEADER, source_file_filter=sources)) | 81 input_api, output_api, _LICENSE_HEADER, source_file_filter=sources)) |
| 82 results.extend(_CheckConstNSObject( |
| 83 input_api, output_api, source_file_filter=sources)) |
| 61 return results | 84 return results |
| 62 | 85 |
| 63 | 86 |
| 64 def CheckChangeOnUpload(input_api, output_api): | 87 def CheckChangeOnUpload(input_api, output_api): |
| 65 results = [] | 88 results = [] |
| 66 results.extend(_CommonChecks(input_api, output_api)) | 89 results.extend(_CommonChecks(input_api, output_api)) |
| 67 return results | 90 return results |
| 68 | 91 |
| 69 | 92 |
| 70 def CheckChangeOnCommit(input_api, output_api): | 93 def CheckChangeOnCommit(input_api, output_api): |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 input_api, | 129 input_api, |
| 107 output_api, | 130 output_api, |
| 108 'http://build.chromium.org/buildbot/waterfall/json/builders?filter=1', | 131 'http://build.chromium.org/buildbot/waterfall/json/builders?filter=1', |
| 109 6, | 132 6, |
| 110 IGNORED_BUILDERS)) | 133 IGNORED_BUILDERS)) |
| 111 return results | 134 return results |
| 112 | 135 |
| 113 | 136 |
| 114 def GetPreferredTrySlaves(): | 137 def GetPreferredTrySlaves(): |
| 115 return ['win', 'linux', 'mac'] | 138 return ['win', 'linux', 'mac'] |
| OLD | NEW |