| 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 29 matching lines...) Expand all Loading... |
| 40 def CheckChangeOnCommit(input_api, output_api): | 40 def CheckChangeOnCommit(input_api, output_api): |
| 41 results = [] | 41 results = [] |
| 42 # TODO(maruel): max_cols is temporarily disabled. Reenable once the source | 42 # TODO(maruel): max_cols is temporarily disabled. Reenable once the source |
| 43 # tree is in better shape. | 43 # tree is in better shape. |
| 44 results.extend(LocalChecks(input_api, output_api, max_cols=0)) | 44 results.extend(LocalChecks(input_api, output_api, max_cols=0)) |
| 45 results.extend(input_api.canned_checks.CheckChangeHasBugField(input_api, | 45 results.extend(input_api.canned_checks.CheckChangeHasBugField(input_api, |
| 46 output_api)) | 46 output_api)) |
| 47 results.extend(input_api.canned_checks.CheckChangeHasTestField(input_api, | 47 results.extend(input_api.canned_checks.CheckChangeHasTestField(input_api, |
| 48 output_api)) | 48 output_api)) |
| 49 # Make sure the tree is 'open'. | 49 # Make sure the tree is 'open'. |
| 50 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 50 results.extend(CheckTreeIsOpen(input_api, output_api, |
| 51 input_api, output_api, | 51 'http://chromium-status.appspot.com/status', |
| 52 'http://chromium-status.appspot.com/status', '0' | 52 '0', |
| 53 )) | 53 'http://chromium-status.appspot.com/current')) |
| 54 results.extend(CheckTryJobExecution(input_api, output_api)) | 54 results.extend(CheckTryJobExecution(input_api, output_api)) |
| 55 return results | 55 return results |
| 56 | 56 |
| 57 | 57 |
| 58 def LocalChecks(input_api, output_api, max_cols=80): | 58 def LocalChecks(input_api, output_api, max_cols=80): |
| 59 """Reports an error if for any source file in SOURCE_FILE_EXTENSIONS: | 59 """Reports an error if for any source file in SOURCE_FILE_EXTENSIONS: |
| 60 - uses CR (or CRLF) | 60 - uses CR (or CRLF) |
| 61 - contains a TAB | 61 - contains a TAB |
| 62 - has a line that ends with whitespace | 62 - has a line that ends with whitespace |
| 63 - contains a line >|max_cols| cols unless |max_cols| is 0. | 63 - contains a line >|max_cols| cols unless |max_cols| is 0. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 # stable enough and it seems to work fine. | 172 # stable enough and it seems to work fine. |
| 173 outputs.append(output_api.PresubmitNotifyResult( | 173 outputs.append(output_api.PresubmitNotifyResult( |
| 174 'You should try the patch first.')) | 174 'You should try the patch first.')) |
| 175 else: | 175 else: |
| 176 # Another HTTP error happened, warn the user. | 176 # Another HTTP error happened, warn the user. |
| 177 # TODO(maruel): Change to a PresubmitPromptWarning once it deemed to work | 177 # TODO(maruel): Change to a PresubmitPromptWarning once it deemed to work |
| 178 # fine. | 178 # fine. |
| 179 outputs.append(output_api.PresubmitNotifyResult( | 179 outputs.append(output_api.PresubmitNotifyResult( |
| 180 'Got %s while looking for try job status.' % str(e))) | 180 'Got %s while looking for try job status.' % str(e))) |
| 181 return outputs | 181 return outputs |
| 182 |
| 183 |
| 184 def CheckTreeIsOpen(input_api, output_api, url, closed, url_text): |
| 185 """Similar to the one in presubmit_canned_checks except it shows an helpful |
| 186 status text instead. |
| 187 """ |
| 188 assert(input_api.is_committing) |
| 189 try: |
| 190 connection = input_api.urllib2.urlopen(url) |
| 191 status = connection.read() |
| 192 connection.close() |
| 193 if input_api.re.match(closed, status): |
| 194 long_text = status + '\n' + url |
| 195 try: |
| 196 connection = input_api.urllib2.urlopen(url_text) |
| 197 text = connection.read() |
| 198 connection.close() |
| 199 match = input_api.re.search(r"\<div class\=\"Notice\"\>(.*)\<\/div\>", |
| 200 text) |
| 201 if match: |
| 202 long_text = match.group(1).strip() |
| 203 except IOError: |
| 204 pass |
| 205 return [output_api.PresubmitPromptWarning("The tree is closed.", |
| 206 long_text=long_text)] |
| 207 except IOError: |
| 208 pass |
| 209 return [] |
| OLD | NEW |