OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Generic presubmit checks that can be reused by other presubmit checks.""" | 5 """Generic presubmit checks that can be reused by other presubmit checks.""" |
6 | 6 |
7 import os as _os | 7 import os as _os |
8 _HERE = _os.path.dirname(_os.path.abspath(__file__)) | 8 _HERE = _os.path.dirname(_os.path.abspath(__file__)) |
9 | 9 |
10 # Justifications for each filter: | 10 # Justifications for each filter: |
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 input_api, output_api, maxlen, source_file_filter=sources)) | 1096 input_api, output_api, maxlen, source_file_filter=sources)) |
1097 snapshot( "checking tabs") | 1097 snapshot( "checking tabs") |
1098 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( | 1098 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( |
1099 input_api, output_api, source_file_filter=sources)) | 1099 input_api, output_api, source_file_filter=sources)) |
1100 snapshot( "checking stray whitespace") | 1100 snapshot( "checking stray whitespace") |
1101 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( | 1101 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( |
1102 input_api, output_api, source_file_filter=sources)) | 1102 input_api, output_api, source_file_filter=sources)) |
1103 snapshot("checking nsobjects") | 1103 snapshot("checking nsobjects") |
1104 results.extend(_CheckConstNSObject( | 1104 results.extend(_CheckConstNSObject( |
1105 input_api, output_api, source_file_filter=sources)) | 1105 input_api, output_api, source_file_filter=sources)) |
| 1106 snapshot("checking eol style") |
| 1107 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle( |
| 1108 input_api, output_api, source_file_filter=text_files)) |
| 1109 snapshot("checking license") |
| 1110 results.extend(input_api.canned_checks.CheckLicense( |
| 1111 input_api, output_api, license_header, source_file_filter=sources)) |
1106 | 1112 |
1107 # The following checks are only done on commit, since the commit bot will | |
1108 # auto-fix most of these. | |
1109 if input_api.is_committing: | 1113 if input_api.is_committing: |
1110 snapshot("checking eol style") | |
1111 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle( | |
1112 input_api, output_api, source_file_filter=text_files)) | |
1113 snapshot("checking svn mime types") | 1114 snapshot("checking svn mime types") |
1114 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( | 1115 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( |
1115 input_api, output_api)) | 1116 input_api, output_api)) |
1116 snapshot("checking license") | |
1117 results.extend(input_api.canned_checks.CheckLicense( | |
1118 input_api, output_api, license_header, source_file_filter=sources)) | |
1119 snapshot("checking was uploaded") | 1117 snapshot("checking was uploaded") |
1120 results.extend(input_api.canned_checks.CheckChangeWasUploaded( | 1118 results.extend(input_api.canned_checks.CheckChangeWasUploaded( |
1121 input_api, output_api)) | 1119 input_api, output_api)) |
1122 snapshot("checking description") | 1120 snapshot("checking description") |
1123 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 1121 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
1124 input_api, output_api)) | 1122 input_api, output_api)) |
1125 results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription( | 1123 results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription( |
1126 input_api, output_api)) | 1124 input_api, output_api)) |
1127 snapshot("checking do not submit in files") | 1125 snapshot("checking do not submit in files") |
1128 results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( | 1126 results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( |
(...skipping 29 matching lines...) Expand all Loading... |
1158 for f in affected_files: | 1156 for f in affected_files: |
1159 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()] | 1157 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()] |
1160 rc = gn.main(cmd) | 1158 rc = gn.main(cmd) |
1161 if rc == 2: | 1159 if rc == 2: |
1162 warnings.append(output_api.PresubmitPromptWarning( | 1160 warnings.append(output_api.PresubmitPromptWarning( |
1163 '%s requires formatting. Please run `gn format --in-place %s`.' % ( | 1161 '%s requires formatting. Please run `gn format --in-place %s`.' % ( |
1164 f.AbsoluteLocalPath(), f.LocalPath()))) | 1162 f.AbsoluteLocalPath(), f.LocalPath()))) |
1165 # It's just a warning, so ignore other types of failures assuming they'll be | 1163 # It's just a warning, so ignore other types of failures assuming they'll be |
1166 # caught elsewhere. | 1164 # caught elsewhere. |
1167 return warnings | 1165 return warnings |
OLD | NEW |