| 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 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 # As this is just a warning, ignore all other errors if the user | 1163 # As this is just a warning, ignore all other errors if the user |
| 1164 # happens to have a broken clang-format, doesn't use git, etc etc. | 1164 # happens to have a broken clang-format, doesn't use git, etc etc. |
| 1165 return [] | 1165 return [] |
| 1166 | 1166 |
| 1167 | 1167 |
| 1168 def CheckGNFormatted(input_api, output_api): | 1168 def CheckGNFormatted(input_api, output_api): |
| 1169 import gn | 1169 import gn |
| 1170 affected_files = input_api.AffectedFiles( | 1170 affected_files = input_api.AffectedFiles( |
| 1171 include_deletes=False, | 1171 include_deletes=False, |
| 1172 file_filter=lambda x: x.LocalPath().endswith('.gn') or | 1172 file_filter=lambda x: x.LocalPath().endswith('.gn') or |
| 1173 x.LocalPath().endswith('.gni')) | 1173 x.LocalPath().endswith('.gni') or |
| 1174 x.LocalPath().endswith('.typemap')) |
| 1174 warnings = [] | 1175 warnings = [] |
| 1175 for f in affected_files: | 1176 for f in affected_files: |
| 1176 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()] | 1177 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()] |
| 1177 rc = gn.main(cmd) | 1178 rc = gn.main(cmd) |
| 1178 if rc == 2: | 1179 if rc == 2: |
| 1179 warnings.append(output_api.PresubmitPromptWarning( | 1180 warnings.append(output_api.PresubmitPromptWarning( |
| 1180 '%s requires formatting. Please run `gn format --in-place %s`.' % ( | 1181 '%s requires formatting. Please run `gn format --in-place %s`.' % ( |
| 1181 f.AbsoluteLocalPath(), f.LocalPath()))) | 1182 f.AbsoluteLocalPath(), f.LocalPath()))) |
| 1182 # It's just a warning, so ignore other types of failures assuming they'll be | 1183 # It's just a warning, so ignore other types of failures assuming they'll be |
| 1183 # caught elsewhere. | 1184 # caught elsewhere. |
| 1184 return warnings | 1185 return warnings |
| OLD | NEW |