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 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 results.extend(_CheckParseErrors(input_api, output_api)) | 1274 results.extend(_CheckParseErrors(input_api, output_api)) |
1275 | 1275 |
1276 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 1276 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
1277 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 1277 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
1278 input_api, output_api, | 1278 input_api, output_api, |
1279 input_api.PresubmitLocalPath(), | 1279 input_api.PresubmitLocalPath(), |
1280 whitelist=[r'^PRESUBMIT_test\.py$'])) | 1280 whitelist=[r'^PRESUBMIT_test\.py$'])) |
1281 return results | 1281 return results |
1282 | 1282 |
1283 | 1283 |
1284 def _CheckSubversionConfig(input_api, output_api): | |
1285 """Verifies the subversion config file is correctly setup. | |
1286 | |
1287 Checks that autoprops are enabled, returns an error otherwise. | |
1288 """ | |
1289 join = input_api.os_path.join | |
1290 if input_api.platform == 'win32': | |
1291 appdata = input_api.environ.get('APPDATA', '') | |
1292 if not appdata: | |
1293 return [output_api.PresubmitError('%APPDATA% is not configured.')] | |
1294 path = join(appdata, 'Subversion', 'config') | |
1295 else: | |
1296 home = input_api.environ.get('HOME', '') | |
1297 if not home: | |
1298 return [output_api.PresubmitError('$HOME is not configured.')] | |
1299 path = join(home, '.subversion', 'config') | |
1300 | |
1301 error_msg = ( | |
1302 'Please look at http://dev.chromium.org/developers/coding-style to\n' | |
1303 'configure your subversion configuration file. This enables automatic\n' | |
1304 'properties to simplify the project maintenance.\n' | |
1305 'Pro-tip: just download and install\n' | |
1306 'http://src.chromium.org/viewvc/chrome/trunk/tools/build/slave/config\n') | |
1307 | |
1308 try: | |
1309 lines = open(path, 'r').read().splitlines() | |
1310 # Make sure auto-props is enabled and check for 2 Chromium standard | |
1311 # auto-prop. | |
1312 if (not '*.cc = svn:eol-style=LF' in lines or | |
1313 not '*.pdf = svn:mime-type=application/pdf' in lines or | |
1314 not 'enable-auto-props = yes' in lines): | |
1315 return [ | |
1316 output_api.PresubmitNotifyResult( | |
1317 'It looks like you have not configured your subversion config ' | |
1318 'file or it is not up-to-date.\n' + error_msg) | |
1319 ] | |
1320 except (OSError, IOError): | |
1321 return [ | |
1322 output_api.PresubmitNotifyResult( | |
1323 'Can\'t find your subversion config file.\n' + error_msg) | |
1324 ] | |
1325 return [] | |
1326 | |
1327 | |
1328 def _CheckAuthorizedAuthor(input_api, output_api): | 1284 def _CheckAuthorizedAuthor(input_api, output_api): |
1329 """For non-googler/chromites committers, verify the author's email address is | 1285 """For non-googler/chromites committers, verify the author's email address is |
1330 in AUTHORS. | 1286 in AUTHORS. |
1331 """ | 1287 """ |
1332 # TODO(maruel): Add it to input_api? | 1288 # TODO(maruel): Add it to input_api? |
1333 import fnmatch | 1289 import fnmatch |
1334 | 1290 |
1335 author = input_api.change.author_email | 1291 author = input_api.change.author_email |
1336 if not author: | 1292 if not author: |
1337 input_api.logging.info('No author, skipping AUTHOR check') | 1293 input_api.logging.info('No author, skipping AUTHOR check') |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1557 # Make sure the tree is 'open'. | 1513 # Make sure the tree is 'open'. |
1558 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 1514 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
1559 input_api, | 1515 input_api, |
1560 output_api, | 1516 output_api, |
1561 json_url='http://chromium-status.appspot.com/current?format=json')) | 1517 json_url='http://chromium-status.appspot.com/current?format=json')) |
1562 | 1518 |
1563 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 1519 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
1564 input_api, output_api)) | 1520 input_api, output_api)) |
1565 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 1521 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
1566 input_api, output_api)) | 1522 input_api, output_api)) |
1567 results.extend(_CheckSubversionConfig(input_api, output_api)) | |
1568 return results | 1523 return results |
1569 | 1524 |
1570 | 1525 |
1571 def GetPreferredTryMasters(project, change): | 1526 def GetPreferredTryMasters(project, change): |
1572 files = change.LocalPaths() | 1527 files = change.LocalPaths() |
1573 | 1528 |
1574 if not files or all(re.search(r'[\\/]OWNERS$', f) for f in files): | 1529 if not files or all(re.search(r'[\\/]OWNERS$', f) for f in files): |
1575 return {} | 1530 return {} |
1576 | 1531 |
1577 if all(re.search('\.(m|mm)$|(^|[/_])mac[/_.]', f) for f in files): | 1532 if all(re.search('\.(m|mm)$|(^|[/_])mac[/_.]', f) for f in files): |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1630 builders.extend(['cros_x86']) | 1585 builders.extend(['cros_x86']) |
1631 | 1586 |
1632 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it | 1587 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it |
1633 # unless they're .gyp(i) files as changes to those files can break the gyp | 1588 # unless they're .gyp(i) files as changes to those files can break the gyp |
1634 # step on that bot. | 1589 # step on that bot. |
1635 if (not all(re.search('^chrome', f) for f in files) or | 1590 if (not all(re.search('^chrome', f) for f in files) or |
1636 any(re.search('\.gypi?$', f) for f in files)): | 1591 any(re.search('\.gypi?$', f) for f in files)): |
1637 builders.extend(['android_aosp']) | 1592 builders.extend(['android_aosp']) |
1638 | 1593 |
1639 return GetDefaultTryConfigs(builders) | 1594 return GetDefaultTryConfigs(builders) |
OLD | NEW |