| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 # will normalize line endings. | 85 # will normalize line endings. |
| 86 contents = ReadFile(path) | 86 contents = ReadFile(path) |
| 87 if '\r' in contents: | 87 if '\r' in contents: |
| 88 cr_files.append(path) | 88 cr_files.append(path) |
| 89 | 89 |
| 90 # Check that the file ends in one and only one newline character. | 90 # Check that the file ends in one and only one newline character. |
| 91 if len(contents) > 0 and (contents[-1:] != "\n" or contents[-2:-1] == "\n"): | 91 if len(contents) > 0 and (contents[-1:] != "\n" or contents[-2:-1] == "\n"): |
| 92 eof_files.append(path) | 92 eof_files.append(path) |
| 93 | 93 |
| 94 local_errors = [] | 94 local_errors = [] |
| 95 # Remove EOL character. | 95 # Remove end of line character. |
| 96 lines = contents.splitlines() | 96 lines = contents.splitlines() |
| 97 line_num = 1 | 97 line_num = 1 |
| 98 for line in lines: | 98 for line in lines: |
| 99 if line.endswith(' '): | 99 if line.endswith(' '): |
| 100 local_errors.append(output_api.PresubmitError( | 100 local_errors.append(output_api.PresubmitError( |
| 101 '%s, line %s ends with whitespaces.' % | 101 '%s, line %s ends with whitespaces.' % |
| 102 (path, line_num))) | 102 (path, line_num))) |
| 103 # Accept lines with http://, https:// and C #define/#pragma/#include to | 103 # Accept lines with http://, https:// and C #define/#pragma/#include to |
| 104 # exceed the max_cols rule. | 104 # exceed the max_cols rule. |
| 105 if (max_cols and | 105 if (max_cols and |
| (...skipping 18 matching lines...) Expand all Loading... |
| 124 | 124 |
| 125 if cr_files: | 125 if cr_files: |
| 126 results.append(output_api.PresubmitError( | 126 results.append(output_api.PresubmitError( |
| 127 'Found CR (or CRLF) line ending in these files, please use only LF:', | 127 'Found CR (or CRLF) line ending in these files, please use only LF:', |
| 128 items=cr_files)) | 128 items=cr_files)) |
| 129 if eof_files: | 129 if eof_files: |
| 130 results.append(output_api.PresubmitError( | 130 results.append(output_api.PresubmitError( |
| 131 'These files should end in one (and only one) newline character:', | 131 'These files should end in one (and only one) newline character:', |
| 132 items=eof_files)) | 132 items=eof_files)) |
| 133 return results | 133 return results |
| OLD | NEW |