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 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 util_log_errors)) | 1439 util_log_errors)) |
1440 | 1440 |
1441 if tag_with_dot_errors: | 1441 if tag_with_dot_errors: |
1442 results.append(output_api.PresubmitPromptWarning( | 1442 results.append(output_api.PresubmitPromptWarning( |
1443 'Dot in log tags cause them to be elided in crash reports.\n' + REF_MSG, | 1443 'Dot in log tags cause them to be elided in crash reports.\n' + REF_MSG, |
1444 tag_with_dot_errors)) | 1444 tag_with_dot_errors)) |
1445 | 1445 |
1446 return results | 1446 return results |
1447 | 1447 |
1448 | 1448 |
| 1449 def _CheckAndroidNewMdpiAssetLocation(input_api, output_api): |
| 1450 """Checks if MDPI assets are placed in a correct directory.""" |
| 1451 file_filter = lambda f: (f.LocalPath().endswith('.png') and |
| 1452 ('/res/drawable/' in f.LocalPath() or |
| 1453 '/res/drawable-ldrtl/' in f.LocalPath())) |
| 1454 errors = [] |
| 1455 for f in input_api.AffectedFiles(include_deletes=False, |
| 1456 file_filter=file_filter): |
| 1457 errors.append(' %s' % f.LocalPath()) |
| 1458 |
| 1459 results = [] |
| 1460 if errors: |
| 1461 results.append(output_api.PresubmitError( |
| 1462 'MDPI assets should be placed in /res/drawable-mdpi/ or ' |
| 1463 '/res/drawable-ldrtl-mdpi/\ninstead of /res/drawable/ and' |
| 1464 '/res/drawable-ldrtl/.\n' |
| 1465 'Contact newt@chromium.org if you have questions.', errors)) |
| 1466 return results |
| 1467 |
| 1468 |
1449 def _CheckForCopyrightedCode(input_api, output_api): | 1469 def _CheckForCopyrightedCode(input_api, output_api): |
1450 """Verifies that newly added code doesn't contain copyrighted material | 1470 """Verifies that newly added code doesn't contain copyrighted material |
1451 and is properly licensed under the standard Chromium license. | 1471 and is properly licensed under the standard Chromium license. |
1452 | 1472 |
1453 As there can be false positives, we maintain a whitelist file. This check | 1473 As there can be false positives, we maintain a whitelist file. This check |
1454 also verifies that the whitelist file is up to date. | 1474 also verifies that the whitelist file is up to date. |
1455 """ | 1475 """ |
1456 import sys | 1476 import sys |
1457 original_sys_path = sys.path | 1477 original_sys_path = sys.path |
1458 try: | 1478 try: |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1568 results.append(output_api.PresubmitError( | 1588 results.append(output_api.PresubmitError( |
1569 "%s:%d: Use of deprecated JS %s, use %s instead" % | 1589 "%s:%d: Use of deprecated JS %s, use %s instead" % |
1570 (fpath.LocalPath(), lnum, deprecated, replacement))) | 1590 (fpath.LocalPath(), lnum, deprecated, replacement))) |
1571 return results | 1591 return results |
1572 | 1592 |
1573 | 1593 |
1574 def _AndroidSpecificOnUploadChecks(input_api, output_api): | 1594 def _AndroidSpecificOnUploadChecks(input_api, output_api): |
1575 """Groups checks that target android code.""" | 1595 """Groups checks that target android code.""" |
1576 results = [] | 1596 results = [] |
1577 results.extend(_CheckAndroidCrLogUsage(input_api, output_api)) | 1597 results.extend(_CheckAndroidCrLogUsage(input_api, output_api)) |
| 1598 results.extend(_CheckAndroidNewMdpiAssetLocation(input_api, output_api)) |
1578 results.extend(_CheckAndroidToastUsage(input_api, output_api)) | 1599 results.extend(_CheckAndroidToastUsage(input_api, output_api)) |
1579 return results | 1600 return results |
1580 | 1601 |
1581 | 1602 |
1582 def _CommonChecks(input_api, output_api): | 1603 def _CommonChecks(input_api, output_api): |
1583 """Checks common to both upload and commit.""" | 1604 """Checks common to both upload and commit.""" |
1584 results = [] | 1605 results = [] |
1585 results.extend(input_api.canned_checks.PanProjectChecks( | 1606 results.extend(input_api.canned_checks.PanProjectChecks( |
1586 input_api, output_api, | 1607 input_api, output_api, |
1587 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS)) | 1608 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS)) |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1928 for master in masters: | 1949 for master in masters: |
1929 try_config.setdefault(master, {}) | 1950 try_config.setdefault(master, {}) |
1930 for builder in masters[master]: | 1951 for builder in masters[master]: |
1931 # Do not trigger presubmit builders, since they're likely to fail | 1952 # Do not trigger presubmit builders, since they're likely to fail |
1932 # (e.g. OWNERS checks before finished code review), and we're | 1953 # (e.g. OWNERS checks before finished code review), and we're |
1933 # running local presubmit anyway. | 1954 # running local presubmit anyway. |
1934 if 'presubmit' not in builder: | 1955 if 'presubmit' not in builder: |
1935 try_config[master][builder] = ['defaulttests'] | 1956 try_config[master][builder] = ['defaulttests'] |
1936 | 1957 |
1937 return try_config | 1958 return try_config |
OLD | NEW |