Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: extensions/common/api/externs_checker.py

Issue 1718243003: [Extern Generation] Add a presubmit script to check externs not being updated (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/common/api/PRESUBMIT.py ('k') | extensions/common/api/externs_checker_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 _GetWarningText(self, entries):
Dan Beam 2016/02/24 19:06:49 I don't really see the point of having this to onl
Devlin 2016/02/25 01:14:11 Done.
16 replacements = (('<source_file>', '<output_file>') if len(entries) > 1 else
17 (entries[0]['source'], entries[0]['extern']))
18 return self._UPDATE_MESSAGE % replacements
19
20 def RunChecks(self):
21 bad_files = []
22 affected = [f.AbsoluteLocalPath() for f in self._input_api.AffectedFiles()]
23 for path in affected:
24 pair = self._api_pairs.get(path)
25 if pair != None and pair not in affected:
26 bad_files.append({'source': path, 'extern': pair})
27 results = []
28 if bad_files:
29 results.append(self._output_api.PresubmitPromptWarning(
30 str('Found updated extension api files without updated extern files. '
31 'Please update the extern files.'),
32 [f['source'] for f in bad_files],
33 self._GetWarningText(bad_files)))
34 return results
OLDNEW
« no previous file with comments | « extensions/common/api/PRESUBMIT.py ('k') | extensions/common/api/externs_checker_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698