OLD | NEW |
1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 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 |
11 EXCLUDED_PATHS = ( | 11 EXCLUDED_PATHS = ( |
12 r"breakpad[\\\/].*", | 12 r"breakpad[\\\/].*", |
13 r"skia[\\\/].*", | 13 r"skia[\\\/].*", |
14 r"v8[\\\/].*", | 14 r"v8[\\\/].*", |
15 ) | 15 ) |
16 | 16 |
17 | 17 |
18 def CheckChangeOnUpload(input_api, output_api): | 18 _LICENSE_HEADER = ( |
| 19 r".*? Copyright \(c\) 20\d\d The Chromium Authors\. All rights reserved\." |
| 20 "\n" |
| 21 r".*? Use of this source code is governed by a BSD-style license that can " |
| 22 "be\n" |
| 23 r".*? found in the LICENSE file\." |
| 24 "\n" |
| 25 ) |
| 26 |
| 27 |
| 28 def _CommonChecks(input_api, output_api): |
19 results = [] | 29 results = [] |
20 # What does this code do? | 30 # What does this code do? |
21 # It loads the default black list (e.g. third_party, experimental, etc) and | 31 # It loads the default black list (e.g. third_party, experimental, etc) and |
22 # add our black list (breakpad, skia and v8 are still not following | 32 # add our black list (breakpad, skia and v8 are still not following |
23 # google style and are not really living this repository). | 33 # google style and are not really living this repository). |
24 # See presubmit_support.py InputApi.FilterSourceFile for the (simple) usage. | 34 # See presubmit_support.py InputApi.FilterSourceFile for the (simple) usage. |
25 black_list = input_api.DEFAULT_BLACK_LIST + EXCLUDED_PATHS | 35 black_list = input_api.DEFAULT_BLACK_LIST + EXCLUDED_PATHS |
26 sources = lambda x: input_api.FilterSourceFile(x, black_list=black_list) | 36 sources = lambda x: input_api.FilterSourceFile(x, black_list=black_list) |
27 results.extend(input_api.canned_checks.CheckLongLines( | 37 results.extend(input_api.canned_checks.CheckLongLines( |
28 input_api, output_api, sources)) | 38 input_api, output_api, sources)) |
29 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( | 39 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( |
30 input_api, output_api, sources)) | 40 input_api, output_api, sources)) |
31 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( | 41 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( |
32 input_api, output_api, sources)) | 42 input_api, output_api, sources)) |
33 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 43 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
34 input_api, output_api)) | 44 input_api, output_api)) |
35 results.extend(input_api.canned_checks.CheckChangeHasTestField( | 45 results.extend(input_api.canned_checks.CheckChangeHasTestField( |
36 input_api, output_api)) | 46 input_api, output_api)) |
37 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle( | 47 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle( |
38 input_api, output_api, sources)) | 48 input_api, output_api, sources)) |
39 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( | 49 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( |
40 input_api, output_api)) | 50 input_api, output_api)) |
| 51 results.extend(input_api.canned_checks.CheckLicense( |
| 52 input_api, output_api, _LICENSE_HEADER, sources)) |
| 53 return results |
| 54 |
| 55 |
| 56 def CheckChangeOnUpload(input_api, output_api): |
| 57 results = [] |
| 58 results.extend(_CommonChecks(input_api, output_api)) |
41 return results | 59 return results |
42 | 60 |
43 | 61 |
44 def CheckChangeOnCommit(input_api, output_api): | 62 def CheckChangeOnCommit(input_api, output_api): |
45 results = [] | 63 results = [] |
46 black_list = input_api.DEFAULT_BLACK_LIST + EXCLUDED_PATHS | 64 results.extend(_CommonChecks(input_api, output_api)) |
47 sources = lambda x: input_api.FilterSourceFile(x, black_list=black_list) | |
48 results.extend(input_api.canned_checks.CheckLongLines( | |
49 input_api, output_api, sources)) | |
50 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( | |
51 input_api, output_api, sources)) | |
52 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( | |
53 input_api, output_api, sources)) | |
54 results.extend(input_api.canned_checks.CheckChangeHasBugField( | |
55 input_api, output_api)) | |
56 results.extend(input_api.canned_checks.CheckChangeHasTestField( | |
57 input_api, output_api)) | |
58 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle( | |
59 input_api, output_api, sources)) | |
60 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( | |
61 input_api, output_api)) | |
62 # TODO(thestig) temporarily disabled, doesn't work in third_party/ | 65 # TODO(thestig) temporarily disabled, doesn't work in third_party/ |
63 #results.extend(input_api.canned_checks.CheckSvnModifiedDirectories( | 66 #results.extend(input_api.canned_checks.CheckSvnModifiedDirectories( |
64 # input_api, output_api, sources)) | 67 # input_api, output_api, sources)) |
65 # Make sure the tree is 'open'. | 68 # Make sure the tree is 'open'. |
66 # TODO(maruel): Run it in a separate thread to parallelize checks? | 69 # TODO(maruel): Run it in a separate thread to parallelize checks? |
67 results.extend(CheckTreeIsOpen( | 70 results.extend(CheckTreeIsOpen( |
68 input_api, | 71 input_api, |
69 output_api, | 72 output_api, |
70 'http://chromium-status.appspot.com/status', | 73 'http://chromium-status.appspot.com/status', |
71 '0', | 74 '0', |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 'builds are pending.' % max_pendings, | 197 'builds are pending.' % max_pendings, |
195 long_text='\n'.join(out))] | 198 long_text='\n'.join(out))] |
196 except IOError: | 199 except IOError: |
197 # Silently pass. | 200 # Silently pass. |
198 pass | 201 pass |
199 return [] | 202 return [] |
200 | 203 |
201 | 204 |
202 def GetPreferredTrySlaves(): | 205 def GetPreferredTrySlaves(): |
203 return ['win', 'linux', 'mac'] | 206 return ['win', 'linux', 'mac'] |
OLD | NEW |