| 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 results = [] |
| 44 input_api.canned_checks.CheckChangeHasBugField(input_api, output_api) + | 44 results.extend(LocalChecks(input_api, output_api, max_cols=0)) |
| 45 input_api.canned_checks.CheckChangeHasTestField(input_api, output_api)) | 45 results.extend(input_api.canned_checks.CheckChangeHasBugField(input_api, |
| 46 output_api)) |
| 47 results.extend(input_api.canned_checks.CheckChangeHasTestField(input_api, |
| 48 output_api)) |
| 49 return results |
| 46 | 50 |
| 47 | 51 |
| 48 def CheckChangeOnCommit(input_api, output_api): | 52 def CheckChangeOnCommit(input_api, output_api): |
| 53 results = [] |
| 49 # TODO(maruel): max_cols is temporarily disabled. Reenable once the source | 54 # TODO(maruel): max_cols is temporarily disabled. Reenable once the source |
| 50 # tree is in better shape. | 55 # tree is in better shape. |
| 51 return (LocalChecks(input_api, output_api, max_cols=0) + | 56 results.extend(LocalChecks(input_api, output_api, max_cols=0)) |
| 52 input_api.canned_checks.CheckDoNotSubmit(input_api, output_api) + | 57 results.extend(input_api.canned_checks.CheckChangeHasBugField(input_api, |
| 53 input_api.canned_checks.CheckChangeHasBugField(input_api, output_api) + | 58 output_api)) |
| 54 input_api.canned_checks.CheckChangeHasTestField(input_api, output_api)) | 59 results.extend(input_api.canned_checks.CheckChangeHasTestField(input_api, |
| 60 output_api)) |
| 61 # Make sure the tree is 'open'. |
| 62 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
| 63 input_api, output_api, |
| 64 'http://chromium-status.appspot.com/status', '0' |
| 65 )) |
| 66 return results |
| 55 | 67 |
| 56 | 68 |
| 57 def LocalChecks(input_api, output_api, max_cols=80): | 69 def LocalChecks(input_api, output_api, max_cols=80): |
| 58 """Reports an error if for any source file in SOURCE_FILE_EXTENSIONS: | 70 """Reports an error if for any source file in SOURCE_FILE_EXTENSIONS: |
| 59 - uses CR (or CRLF) | 71 - uses CR (or CRLF) |
| 60 - contains a TAB | 72 - contains a TAB |
| 61 - has a line that ends with whitespace | 73 - has a line that ends with whitespace |
| 62 - contains a line >|max_cols| cols unless |max_cols| is 0. | 74 - contains a line >|max_cols| cols unless |max_cols| is 0. |
| 63 - File does not end in a newline, or ends in more than one. | 75 - File does not end in a newline, or ends in more than one. |
| 64 | 76 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 140 |
| 129 if cr_files: | 141 if cr_files: |
| 130 results.append(output_api.PresubmitError( | 142 results.append(output_api.PresubmitError( |
| 131 'Found CR (or CRLF) line ending in these files, please use only LF:', | 143 'Found CR (or CRLF) line ending in these files, please use only LF:', |
| 132 items=cr_files)) | 144 items=cr_files)) |
| 133 if eof_files: | 145 if eof_files: |
| 134 results.append(output_api.PresubmitError( | 146 results.append(output_api.PresubmitError( |
| 135 'These files should end in one (and only one) newline character:', | 147 'These files should end in one (and only one) newline character:', |
| 136 items=eof_files)) | 148 items=eof_files)) |
| 137 return results | 149 return results |
| OLD | NEW |