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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 input_api.AffectedFiles()): | 389 input_api.AffectedFiles()): |
390 return [output_api.PresubmitError( | 390 return [output_api.PresubmitError( |
391 'Never commit changes to .DEPS.git. This file is maintained by an\n' | 391 'Never commit changes to .DEPS.git. This file is maintained by an\n' |
392 'automated system based on what\'s in DEPS and your changes will be\n' | 392 'automated system based on what\'s in DEPS and your changes will be\n' |
393 'overwritten.\n' | 393 'overwritten.\n' |
394 'See https://sites.google.com/a/chromium.org/dev/developers/how-tos/get-th e-code#Rolling_DEPS\n' | 394 'See https://sites.google.com/a/chromium.org/dev/developers/how-tos/get-th e-code#Rolling_DEPS\n' |
395 'for more information')] | 395 'for more information')] |
396 return [] | 396 return [] |
397 | 397 |
398 | 398 |
399 def _CheckValidHostsInDEPS(input_api, output_api): | |
400 """Checks that DEPS file deps are from allowed_hosts.""" | |
401 # Run only if DEPS file has been modified to annoy fewer bystanders. | |
402 for f in input_api.AffectedFiles(): | |
403 if f.LocalPath().endswith("DEPS"): | |
404 break | |
iannucci
2014/09/18 21:05:13
why not
if 'DEPS' not in input_api.AffectedFiles(
tandrii(chromium)
2014/09/18 22:01:36
Good point, though AffectedFiles() isn't a list of
| |
405 else: | |
406 return [] | |
407 # Outsource work to gclient verify | |
408 try: | |
409 input_api.subprocess.check_output(['gclient', 'verify']) | |
410 return [] | |
411 except input_api.subprocess.CalledProcessError, error: | |
412 return [output_api.PresubmitError( | |
413 'DEPS file must have only git dependencies.', | |
414 # Python's subprocess.check_call docs says .output attribute contains | |
415 # output. However, the subprocess is our wrapper (in depot_tools), | |
416 # and it differs by storing stdout in stdout, and output is never set. | |
417 long_text=error.output or error.stdout)] | |
iannucci
2014/09/18 21:05:13
ugh, this is exactly what I'm worried about.
tandrii(chromium)
2014/09/18 22:01:36
As you have already seen, https://codereview.chrom
| |
418 | |
419 | |
399 def _CheckNoBannedFunctions(input_api, output_api): | 420 def _CheckNoBannedFunctions(input_api, output_api): |
400 """Make sure that banned functions are not used.""" | 421 """Make sure that banned functions are not used.""" |
401 warnings = [] | 422 warnings = [] |
402 errors = [] | 423 errors = [] |
403 | 424 |
404 file_filter = lambda f: f.LocalPath().endswith(('.mm', '.m', '.h')) | 425 file_filter = lambda f: f.LocalPath().endswith(('.mm', '.m', '.h')) |
405 for f in input_api.AffectedFiles(file_filter=file_filter): | 426 for f in input_api.AffectedFiles(file_filter=file_filter): |
406 for line_num, line in f.ChangedContents(): | 427 for line_num, line in f.ChangedContents(): |
407 for func_name, message, error in _BANNED_OBJC_FUNCTIONS: | 428 for func_name, message, error in _BANNED_OBJC_FUNCTIONS: |
408 matched = False | 429 matched = False |
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1399 if problems: | 1420 if problems: |
1400 return [output_api.PresubmitPromptWarning( | 1421 return [output_api.PresubmitPromptWarning( |
1401 _IPC_ENUM_TRAITS_DEPRECATED, problems)] | 1422 _IPC_ENUM_TRAITS_DEPRECATED, problems)] |
1402 else: | 1423 else: |
1403 return [] | 1424 return [] |
1404 | 1425 |
1405 | 1426 |
1406 def CheckChangeOnUpload(input_api, output_api): | 1427 def CheckChangeOnUpload(input_api, output_api): |
1407 results = [] | 1428 results = [] |
1408 results.extend(_CommonChecks(input_api, output_api)) | 1429 results.extend(_CommonChecks(input_api, output_api)) |
1430 results.extend(_CheckValidHostsInDEPS(input_api, output_api)) | |
1409 results.extend(_CheckJavaStyle(input_api, output_api)) | 1431 results.extend(_CheckJavaStyle(input_api, output_api)) |
1410 return results | 1432 return results |
1411 | 1433 |
1412 | 1434 |
1413 def GetTryServerMasterForBot(bot): | 1435 def GetTryServerMasterForBot(bot): |
1414 """Returns the Try Server master for the given bot. | 1436 """Returns the Try Server master for the given bot. |
1415 | 1437 |
1416 It tries to guess the master from the bot name, but may still fail | 1438 It tries to guess the master from the bot name, but may still fail |
1417 and return None. There is no longer a default master. | 1439 and return None. There is no longer a default master. |
1418 """ | 1440 """ |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1621 builders.extend(['cros_x86']) | 1643 builders.extend(['cros_x86']) |
1622 | 1644 |
1623 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it | 1645 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it |
1624 # unless they're .gyp(i) files as changes to those files can break the gyp | 1646 # unless they're .gyp(i) files as changes to those files can break the gyp |
1625 # step on that bot. | 1647 # step on that bot. |
1626 if (not all(re.search('^chrome', f) for f in files) or | 1648 if (not all(re.search('^chrome', f) for f in files) or |
1627 any(re.search('\.gypi?$', f) for f in files)): | 1649 any(re.search('\.gypi?$', f) for f in files)): |
1628 builders.extend(['android_aosp']) | 1650 builders.extend(['android_aosp']) |
1629 | 1651 |
1630 return GetDefaultTryConfigs(builders) | 1652 return GetDefaultTryConfigs(builders) |
OLD | NEW |