OLD | NEW |
| (Empty) |
1 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | |
2 # | |
3 # Use of this source code is governed by a BSD-style license | |
4 # that can be found in the LICENSE file in the root of the source | |
5 # tree. An additional intellectual property rights grant can be found | |
6 # in the file PATENTS. All contributing project authors may | |
7 # be found in the AUTHORS file in the root of the source tree. | |
8 | |
9 def CheckChangeOnUpload(input_api, output_api): | |
10 results = [] | |
11 results.extend(CheckPatchFormatted(input_api, output_api)) | |
12 return results | |
13 | |
14 def CheckPatchFormatted(input_api, output_api): | |
15 import git_cl | |
16 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()] | |
17 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True) | |
18 if code == 2: | |
19 short_path = input_api.basename(input_api.PresubmitLocalPath()) | |
20 full_path = input_api.os_path.relpath(input_api.PresubmitLocalPath(), | |
21 input_api.change.RepositoryRoot()) | |
22 return [output_api.PresubmitPromptWarning( | |
23 'The %s directory requires source formatting. ' | |
24 'Please run git cl format %s' % | |
25 (short_path, full_path))] | |
26 # As this is just a warning, ignore all other errors if the user | |
27 # happens to have a broken clang-format, doesn't use git, etc etc. | |
28 return [] | |
OLD | NEW |