Chromium Code Reviews| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 files.append(f) | 61 files.append(f) |
| 62 | 62 |
| 63 if len(files): | 63 if len(files): |
| 64 return [ output_api.PresubmitError( | 64 return [ output_api.PresubmitError( |
| 65 'Found Singleton<T> in the following header files.\n' + | 65 'Found Singleton<T> in the following header files.\n' + |
| 66 'Please move them to an appropriate source file so that the ' + | 66 'Please move them to an appropriate source file so that the ' + |
| 67 'template gets instantiated in a single compilation unit.', | 67 'template gets instantiated in a single compilation unit.', |
| 68 files) ] | 68 files) ] |
| 69 return [] | 69 return [] |
| 70 | 70 |
| 71 | |
| 72 def _CheckSubversionConfig(input_api, output_api): | |
| 73 """Verifies the subversion config file is correctly setup. | |
| 74 | |
| 75 Checks that autoprops are enabled, returns an error otherwise. | |
| 76 """ | |
| 77 join = input_api.os_path.join | |
| 78 if input_api.platform == 'win32': | |
| 79 appdata = input_api.environ.get('APPDATA', '') | |
| 80 if not appdata: | |
| 81 return [output_api.PresubmitError('%APPDATA% is not configured.')] | |
| 82 path = join(appdata, 'Subversion', 'config') | |
| 83 else: | |
| 84 home = input_api.environ.get('HOME', '') | |
| 85 if not home: | |
| 86 return [output_api.PresubmitError('$HOME is not configured.')] | |
| 87 path = join(home, '.subversion', 'config') | |
| 88 | |
| 89 error_msg = ( | |
| 90 'Please look at http://dev.chromium.org/developers/coding-style to\n' | |
| 91 'configure your subversion configuration file. This enables automatic\n' | |
| 92 'properties to simplify the project maintenance.') | |
| 93 | |
| 94 try: | |
| 95 lines = open(path, 'r').read().splitlines() | |
| 96 # Make sure auto-props is enabled and check for 2 Chromium standard | |
| 97 # auto-prop. | |
| 98 if (not '*.cc = svn:eol-style=LF' in lines or | |
| 99 not '*.pdf = svn:mime-type=application/pdf' in lines or | |
| 100 not 'enable-auto-props = yes' in lines): | |
| 101 return [ | |
| 102 output_api.PresubmitError( | |
| 103 'It looks like you have not configured your subversion config ' | |
| 104 'file.\n' + error_msg) | |
|
wtc
2011/01/31 22:37:36
I got this error message when I tried to commit a
| |
| 105 ] | |
| 106 except (OSError, IOError): | |
| 107 return [ | |
| 108 output_api.PresubmitError( | |
| 109 'Can\'t find your subversion config file.\n' + error_msg) | |
| 110 ] | |
| 111 return [] | |
| 112 | |
| 113 | |
| 71 def _CheckConstNSObject(input_api, output_api, source_file_filter): | 114 def _CheckConstNSObject(input_api, output_api, source_file_filter): |
| 72 """Checks to make sure no objective-c files have |const NSSomeClass*|.""" | 115 """Checks to make sure no objective-c files have |const NSSomeClass*|.""" |
| 73 pattern = input_api.re.compile(r'const\s+NS\w*\s*\*') | 116 pattern = input_api.re.compile(r'const\s+NS\w*\s*\*') |
| 74 files = [] | 117 files = [] |
| 75 for f in input_api.AffectedSourceFiles(source_file_filter): | 118 for f in input_api.AffectedSourceFiles(source_file_filter): |
| 76 if f.LocalPath().endswith('.h') or f.LocalPath().endswith('.mm'): | 119 if f.LocalPath().endswith('.h') or f.LocalPath().endswith('.mm'): |
| 77 contents = input_api.ReadFile(f) | 120 contents = input_api.ReadFile(f) |
| 78 if pattern.search(contents): | 121 if pattern.search(contents): |
| 79 files.append(f) | 122 files.append(f) |
| 80 | 123 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 results.extend(input_api.canned_checks.CheckBuildbotPendingBuilds( | 208 results.extend(input_api.canned_checks.CheckBuildbotPendingBuilds( |
| 166 input_api, | 209 input_api, |
| 167 output_api, | 210 output_api, |
| 168 'http://build.chromium.org/p/chromium/json/builders?filter=1', | 211 'http://build.chromium.org/p/chromium/json/builders?filter=1', |
| 169 6, | 212 6, |
| 170 IGNORED_BUILDERS)) | 213 IGNORED_BUILDERS)) |
| 171 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 214 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
| 172 input_api, output_api)) | 215 input_api, output_api)) |
| 173 results.extend(input_api.canned_checks.CheckChangeHasTestField( | 216 results.extend(input_api.canned_checks.CheckChangeHasTestField( |
| 174 input_api, output_api)) | 217 input_api, output_api)) |
| 218 results.extend(_CheckSubversionConfig(input_api, output_api)) | |
| 175 return results | 219 return results |
| 176 | 220 |
| 177 | 221 |
| 178 def GetPreferredTrySlaves(): | 222 def GetPreferredTrySlaves(): |
| 179 return ['win', 'linux', 'mac'] | 223 return ['win', 'linux', 'mac'] |
| OLD | NEW |