OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Top-level presubmit script for Chromium. | 6 """Top-level presubmit script for Chromium. |
7 | 7 |
8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for | 8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for |
9 details on the presubmit API built into gcl. | 9 details on the presubmit API built into gcl. |
10 """ | 10 """ |
(...skipping 22 matching lines...) Expand all Loading... |
33 try: | 33 try: |
34 contents = fo.read() | 34 contents = fo.read() |
35 finally: | 35 finally: |
36 fo.close() | 36 fo.close() |
37 return contents | 37 return contents |
38 | 38 |
39 | 39 |
40 def CheckChangeOnUpload(input_api, output_api): | 40 def CheckChangeOnUpload(input_api, output_api): |
41 # TODO(maruel): max_cols is temporarily disabled. Reenable once the source | 41 # TODO(maruel): max_cols is temporarily disabled. Reenable once the source |
42 # tree is in better shape. | 42 # tree is in better shape. |
43 return LocalChecks(input_api, output_api, max_cols=0) | 43 return (LocalChecks(input_api, output_api, max_cols=0) + |
| 44 input_api.canned_checks.CheckChangeHasBugField(input_api, output_api) + |
| 45 input_api.canned_checks.CheckChangeHasTestField(input_api, output_api)) |
44 | 46 |
45 | 47 |
46 def CheckChangeOnCommit(input_api, output_api): | 48 def CheckChangeOnCommit(input_api, output_api): |
47 # TODO(maruel): max_cols is temporarily disabled. Reenable once the source | 49 # TODO(maruel): max_cols is temporarily disabled. Reenable once the source |
48 # tree is in better shape. | 50 # tree is in better shape. |
49 return (LocalChecks(input_api, output_api, max_cols=0) + | 51 return (LocalChecks(input_api, output_api, max_cols=0) + |
50 input_api.canned_checks.CheckDoNotSubmit(input_api, output_api)) | 52 input_api.canned_checks.CheckDoNotSubmit(input_api, output_api) + |
| 53 input_api.canned_checks.CheckChangeHasBugField(input_api, output_api) + |
| 54 input_api.canned_checks.CheckChangeHasTestField(input_api, output_api)) |
51 | 55 |
52 | 56 |
53 def LocalChecks(input_api, output_api, max_cols=80): | 57 def LocalChecks(input_api, output_api, max_cols=80): |
54 """Reports an error if for any source file in SOURCE_FILE_EXTENSIONS: | 58 """Reports an error if for any source file in SOURCE_FILE_EXTENSIONS: |
55 - uses CR (or CRLF) | 59 - uses CR (or CRLF) |
56 - contains a TAB | 60 - contains a TAB |
57 - has a line that ends with whitespace | 61 - has a line that ends with whitespace |
58 - contains a line >|max_cols| cols unless |max_cols| is 0. | 62 - contains a line >|max_cols| cols unless |max_cols| is 0. |
59 - File does not end in a newline, or ends in more than one. | 63 - File does not end in a newline, or ends in more than one. |
60 | 64 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 128 |
125 if cr_files: | 129 if cr_files: |
126 results.append(output_api.PresubmitError( | 130 results.append(output_api.PresubmitError( |
127 'Found CR (or CRLF) line ending in these files, please use only LF:', | 131 'Found CR (or CRLF) line ending in these files, please use only LF:', |
128 items=cr_files)) | 132 items=cr_files)) |
129 if eof_files: | 133 if eof_files: |
130 results.append(output_api.PresubmitError( | 134 results.append(output_api.PresubmitError( |
131 'These files should end in one (and only one) newline character:', | 135 'These files should end in one (and only one) newline character:', |
132 items=eof_files)) | 136 items=eof_files)) |
133 return results | 137 return results |
OLD | NEW |