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 depot_tools. | 8 for more details about the presubmit API built into depot_tools. |
9 """ | 9 """ |
10 | 10 |
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 if bad_pattern.search(line) and not good_pattern.search(line): | 1240 if bad_pattern.search(line) and not good_pattern.search(line): |
1241 errors.append('%s:%d' % (f.LocalPath(), linenum)) | 1241 errors.append('%s:%d' % (f.LocalPath(), linenum)) |
1242 | 1242 |
1243 if errors: | 1243 if errors: |
1244 return [output_api.PresubmitError( | 1244 return [output_api.PresubmitError( |
1245 'These lines create anonymous variables that need to be named:', | 1245 'These lines create anonymous variables that need to be named:', |
1246 items=errors)] | 1246 items=errors)] |
1247 return [] | 1247 return [] |
1248 | 1248 |
1249 | 1249 |
1250 def _CheckCygwinShell(input_api, output_api): | |
1251 source_file_filter = lambda x: input_api.FilterSourceFile( | |
1252 x, white_list=(r'.+\.(gyp|gypi)$',)) | |
1253 cygwin_shell = [] | |
1254 | |
1255 for f in input_api.AffectedSourceFiles(source_file_filter): | |
1256 for linenum, line in f.ChangedContents(): | |
1257 if 'msvs_cygwin_shell' in line: | |
1258 cygwin_shell.append(f.LocalPath()) | |
1259 break | |
1260 | |
1261 if cygwin_shell: | |
1262 return [output_api.PresubmitError( | |
1263 'These files should not use msvs_cygwin_shell (the default is 0):', | |
1264 items=cygwin_shell)] | |
1265 return [] | |
1266 | |
1267 | |
1268 def _CheckUserActionUpdate(input_api, output_api): | 1250 def _CheckUserActionUpdate(input_api, output_api): |
1269 """Checks if any new user action has been added.""" | 1251 """Checks if any new user action has been added.""" |
1270 if any('actions.xml' == input_api.os_path.basename(f) for f in | 1252 if any('actions.xml' == input_api.os_path.basename(f) for f in |
1271 input_api.LocalPaths()): | 1253 input_api.LocalPaths()): |
1272 # If actions.xml is already included in the changelist, the PRESUBMIT | 1254 # If actions.xml is already included in the changelist, the PRESUBMIT |
1273 # for actions.xml will do a more complete presubmit check. | 1255 # for actions.xml will do a more complete presubmit check. |
1274 return [] | 1256 return [] |
1275 | 1257 |
1276 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.mm')) | 1258 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.mm')) |
1277 action_re = r'[^a-zA-Z]UserMetricsAction\("([^"]*)' | 1259 action_re = r'[^a-zA-Z]UserMetricsAction\("([^"]*)' |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1991 results.extend(_CheckForInvalidIfDefinedMacros(input_api, output_api)) | 1973 results.extend(_CheckForInvalidIfDefinedMacros(input_api, output_api)) |
1992 results.extend(_CheckFlakyTestUsage(input_api, output_api)) | 1974 results.extend(_CheckFlakyTestUsage(input_api, output_api)) |
1993 results.extend(_CheckAddedDepsHaveTargetApprovals(input_api, output_api)) | 1975 results.extend(_CheckAddedDepsHaveTargetApprovals(input_api, output_api)) |
1994 results.extend( | 1976 results.extend( |
1995 input_api.canned_checks.CheckChangeHasNoTabs( | 1977 input_api.canned_checks.CheckChangeHasNoTabs( |
1996 input_api, | 1978 input_api, |
1997 output_api, | 1979 output_api, |
1998 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) | 1980 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) |
1999 results.extend(_CheckSpamLogging(input_api, output_api)) | 1981 results.extend(_CheckSpamLogging(input_api, output_api)) |
2000 results.extend(_CheckForAnonymousVariables(input_api, output_api)) | 1982 results.extend(_CheckForAnonymousVariables(input_api, output_api)) |
2001 results.extend(_CheckCygwinShell(input_api, output_api)) | |
2002 results.extend(_CheckUserActionUpdate(input_api, output_api)) | 1983 results.extend(_CheckUserActionUpdate(input_api, output_api)) |
2003 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) | 1984 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) |
2004 results.extend(_CheckNoDeprecatedJS(input_api, output_api)) | 1985 results.extend(_CheckNoDeprecatedJS(input_api, output_api)) |
2005 results.extend(_CheckParseErrors(input_api, output_api)) | 1986 results.extend(_CheckParseErrors(input_api, output_api)) |
2006 results.extend(_CheckForIPCRules(input_api, output_api)) | 1987 results.extend(_CheckForIPCRules(input_api, output_api)) |
2007 results.extend(_CheckForCopyrightedCode(input_api, output_api)) | 1988 results.extend(_CheckForCopyrightedCode(input_api, output_api)) |
2008 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) | 1989 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) |
2009 results.extend(_CheckSingletonInHeaders(input_api, output_api)) | 1990 results.extend(_CheckSingletonInHeaders(input_api, output_api)) |
2010 results.extend(_CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api)) | 1991 results.extend(_CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api)) |
2011 results.extend(_CheckPydepsNeedsUpdating(input_api, output_api)) | 1992 results.extend(_CheckPydepsNeedsUpdating(input_api, output_api)) |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2270 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 2251 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
2271 input_api, | 2252 input_api, |
2272 output_api, | 2253 output_api, |
2273 json_url='http://chromium-status.appspot.com/current?format=json')) | 2254 json_url='http://chromium-status.appspot.com/current?format=json')) |
2274 | 2255 |
2275 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 2256 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
2276 input_api, output_api)) | 2257 input_api, output_api)) |
2277 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 2258 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
2278 input_api, output_api)) | 2259 input_api, output_api)) |
2279 return results | 2260 return results |
OLD | NEW |