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 | 10 |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 return results | 1100 return results |
1101 | 1101 |
1102 | 1102 |
1103 def CheckPatchFormatted(input_api, output_api): | 1103 def CheckPatchFormatted(input_api, output_api): |
1104 import git_cl | 1104 import git_cl |
1105 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()] | 1105 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()] |
1106 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True) | 1106 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True) |
1107 if code == 2: | 1107 if code == 2: |
1108 return [output_api.PresubmitPromptWarning( | 1108 return [output_api.PresubmitPromptWarning( |
1109 'The %s directory requires clang-formatting. ' | 1109 'The %s directory requires clang-formatting. ' |
1110 'Please run git cl format %s' % (input_api.basename, input_api.basename))] | 1110 'Please run git cl format %s' % |
| 1111 (input_api.basename(input_api.PresubmitLocalPath()), |
| 1112 input_api.basename(input_api.PresubmitLocalPath())))] |
1111 # As this is just a warning, ignore all other errors if the user | 1113 # As this is just a warning, ignore all other errors if the user |
1112 # happens to have a broken clang-format, doesn't use git, etc etc. | 1114 # happens to have a broken clang-format, doesn't use git, etc etc. |
1113 return [] | 1115 return [] |
OLD | NEW |