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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 - contains a line >|max_cols| cols unless |max_cols| is 0. | 62 - 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. | 63 - File does not end in a newline, or ends in more than one. |
64 | 64 |
65 Note that the whole file is checked, not only the changes. | 65 Note that the whole file is checked, not only the changes. |
66 """ | 66 """ |
67 C_SOURCE_FILE_EXTENSIONS = ('.c', '.cc', '.cpp', '.h', '.inl') | 67 C_SOURCE_FILE_EXTENSIONS = ('.c', '.cc', '.cpp', '.h', '.inl') |
68 cr_files = [] | 68 cr_files = [] |
69 eof_files = [] | 69 eof_files = [] |
70 results = [] | 70 results = [] |
71 excluded_paths = [input_api.re.compile(x) for x in EXCLUDED_PATHS] | 71 excluded_paths = [input_api.re.compile(x) for x in EXCLUDED_PATHS] |
72 files = input_api.AffectedFiles() | 72 files = input_api.AffectedFiles(include_deletes=False) |
73 for f in files: | 73 for f in files: |
74 path = f.LocalPath() | 74 path = f.LocalPath() |
75 root, ext = input_api.os_path.splitext(path) | 75 root, ext = input_api.os_path.splitext(path) |
76 # Look for unsupported extensions. | 76 # Look for unsupported extensions. |
77 if not ext in SOURCE_FILE_EXTENSIONS: | 77 if not ext in SOURCE_FILE_EXTENSIONS: |
78 continue | 78 continue |
79 # Look for excluded paths. | 79 # Look for excluded paths. |
80 found = False | 80 found = False |
81 for item in excluded_paths: | 81 for item in excluded_paths: |
82 if item.match(path): | 82 if item.match(path): |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 if cr_files: | 129 if cr_files: |
130 results.append(output_api.PresubmitError( | 130 results.append(output_api.PresubmitError( |
131 '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:', |
132 items=cr_files)) | 132 items=cr_files)) |
133 if eof_files: | 133 if eof_files: |
134 results.append(output_api.PresubmitError( | 134 results.append(output_api.PresubmitError( |
135 'These files should end in one (and only one) newline character:', | 135 'These files should end in one (and only one) newline character:', |
136 items=eof_files)) | 136 items=eof_files)) |
137 return results | 137 return results |
OLD | NEW |