OLD | NEW |
---|---|
(Empty) | |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 class ExternsChecker(object): | |
6 _UPDATE_MESSAGE = """To update the externs, run: | |
7 src/ $ python tools/json_schema_compiler/compiler.py\ | |
8 %s --root=. --generator=externs > %s""" | |
9 | |
10 def __init__(self, input_api, output_api, api_pairs): | |
11 self._input_api = input_api | |
12 self._output_api = output_api | |
13 self._api_pairs = api_pairs | |
14 | |
15 def RunChecks(self): | |
16 bad_files = [] | |
17 affected = [f.AbsoluteLocalPath() for f in self._input_api.AffectedFiles()] | |
18 for path in affected: | |
19 pair = self._api_pairs.get(path) | |
20 if pair != None and pair not in affected: | |
21 bad_files.append({'source': path, 'extern': pair}) | |
22 results = [] | |
23 if bad_files: | |
24 replacements = (('<source_file>', '<output_file>') if len(bad_files) > 1 e lse | |
Dan Beam
2016/02/25 01:42:53
80 col wrap
| |
25 (bad_files[0]['source'], bad_files[0]['extern'])) | |
26 long_text = self._UPDATE_MESSAGE % replacements | |
27 results.append(self._output_api.PresubmitPromptWarning( | |
28 str('Found updated extension api files without updated extern files. ' | |
29 'Please update the extern files.'), | |
30 [f['source'] for f in bad_files], | |
31 long_text)) | |
32 return results | |
OLD | NEW |