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 1928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1939 | 1939 |
1940 | 1940 |
1941 def _AndroidSpecificOnUploadChecks(input_api, output_api): | 1941 def _AndroidSpecificOnUploadChecks(input_api, output_api): |
1942 """Groups checks that target android code.""" | 1942 """Groups checks that target android code.""" |
1943 results = [] | 1943 results = [] |
1944 results.extend(_CheckAndroidCrLogUsage(input_api, output_api)) | 1944 results.extend(_CheckAndroidCrLogUsage(input_api, output_api)) |
1945 results.extend(_CheckAndroidNewMdpiAssetLocation(input_api, output_api)) | 1945 results.extend(_CheckAndroidNewMdpiAssetLocation(input_api, output_api)) |
1946 results.extend(_CheckAndroidToastUsage(input_api, output_api)) | 1946 results.extend(_CheckAndroidToastUsage(input_api, output_api)) |
1947 return results | 1947 return results |
1948 | 1948 |
| 1949 def _CheckNewSourceFileAddedToGnGypi(input_api, output_api): |
| 1950 """Checks new source code files were added to GN/GYPi files""" |
| 1951 new_source_files = [] |
| 1952 gn_gypi_files = [] |
| 1953 |
| 1954 """ Get lists of new source code files and GN/GYPi files in the commit""" |
| 1955 for f in input_api.AffectedFiles(): |
| 1956 if f.LocalPath().endswith(('.gn', '.gypi')): |
| 1957 gn_gypi_files.append(f) |
| 1958 continue |
| 1959 if f.LocalPath().endswith(('.h', '.c', '.cc', '.m', '.mm', '.java')): |
| 1960 if f.Action() == 'A': |
| 1961 new_source_files.append(f.LocalPath()) |
| 1962 |
| 1963 if not new_source_files: |
| 1964 return [] |
| 1965 |
| 1966 if not gn_gypi_files: |
| 1967 return [output_api.PresubmitPromptWarning('The following new' |
| 1968 ' source code files must be added to GN/GYPI files:\n ' + |
| 1969 '\n '.join(new_source_files))] |
| 1970 |
| 1971 """Get a list of new source code files that CAN BE FOUND in the GN/GYPI |
| 1972 files""" |
| 1973 source_files_listed = [] |
| 1974 for f in new_source_files: |
| 1975 head, sep, tail = f.rpartition('/') |
| 1976 source_file_match_pattern = tail |
| 1977 for g in gn_gypi_files: |
| 1978 for line in g.GenerateScmDiff().splitlines(): |
| 1979 if line.endswith((source_file_match_pattern + '",', |
| 1980 source_file_match_pattern + '\',')): |
| 1981 source_files_listed.append(f) |
| 1982 break |
| 1983 |
| 1984 """Remove files, which has been found in the GN files, from the list""" |
| 1985 for f in source_files_listed: |
| 1986 if f in new_source_files: |
| 1987 new_source_files.remove(f) |
| 1988 |
| 1989 if new_source_files: |
| 1990 return [output_api.PresubmitPromptWarning('The following new' |
| 1991 ' source code files must be added to GN/GYPI files:\n ' + |
| 1992 '\n '.join(new_source_files))] |
| 1993 |
| 1994 return [] |
1949 | 1995 |
1950 def _CommonChecks(input_api, output_api): | 1996 def _CommonChecks(input_api, output_api): |
1951 """Checks common to both upload and commit.""" | 1997 """Checks common to both upload and commit.""" |
1952 results = [] | 1998 results = [] |
1953 results.extend(input_api.canned_checks.PanProjectChecks( | 1999 results.extend(input_api.canned_checks.PanProjectChecks( |
1954 input_api, output_api, | 2000 input_api, output_api, |
1955 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS)) | 2001 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS)) |
1956 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) | 2002 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) |
1957 results.extend( | 2003 results.extend( |
1958 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) | 2004 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2201 | 2247 |
2202 | 2248 |
2203 def CheckChangeOnUpload(input_api, output_api): | 2249 def CheckChangeOnUpload(input_api, output_api): |
2204 results = [] | 2250 results = [] |
2205 results.extend(_CommonChecks(input_api, output_api)) | 2251 results.extend(_CommonChecks(input_api, output_api)) |
2206 results.extend(_CheckValidHostsInDEPS(input_api, output_api)) | 2252 results.extend(_CheckValidHostsInDEPS(input_api, output_api)) |
2207 results.extend( | 2253 results.extend( |
2208 input_api.canned_checks.CheckGNFormatted(input_api, output_api)) | 2254 input_api.canned_checks.CheckGNFormatted(input_api, output_api)) |
2209 results.extend(_CheckUmaHistogramChanges(input_api, output_api)) | 2255 results.extend(_CheckUmaHistogramChanges(input_api, output_api)) |
2210 results.extend(_AndroidSpecificOnUploadChecks(input_api, output_api)) | 2256 results.extend(_AndroidSpecificOnUploadChecks(input_api, output_api)) |
| 2257 results.extend(_CheckNewSourceFileAddedToGnGypi(input_api, output_api)) |
2211 return results | 2258 return results |
2212 | 2259 |
2213 | 2260 |
2214 def GetTryServerMasterForBot(bot): | 2261 def GetTryServerMasterForBot(bot): |
2215 """Returns the Try Server master for the given bot. | 2262 """Returns the Try Server master for the given bot. |
2216 | 2263 |
2217 It tries to guess the master from the bot name, but may still fail | 2264 It tries to guess the master from the bot name, but may still fail |
2218 and return None. There is no longer a default master. | 2265 and return None. There is no longer a default master. |
2219 """ | 2266 """ |
2220 # Potentially ambiguous bot names are listed explicitly. | 2267 # Potentially ambiguous bot names are listed explicitly. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2255 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 2302 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
2256 input_api, | 2303 input_api, |
2257 output_api, | 2304 output_api, |
2258 json_url='http://chromium-status.appspot.com/current?format=json')) | 2305 json_url='http://chromium-status.appspot.com/current?format=json')) |
2259 | 2306 |
2260 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 2307 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
2261 input_api, output_api)) | 2308 input_api, output_api)) |
2262 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 2309 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
2263 input_api, output_api)) | 2310 input_api, output_api)) |
2264 return results | 2311 return results |
OLD | NEW |