Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
|
Alexei Svitkine (slow)
2014/11/11 20:36:41
Nit: "Copyright 2014" (no (c))
gayane -on leave until 09-2017
2014/11/12 22:00:23
Done.
| |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 """Presubmit script for HTML files in . | |
| 5 | |
| 6 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | |
| 7 for more details about the presubmit API built into gcl. | |
| 8 """ | |
| 9 | |
| 10 def CheckUserActionUpdate(input_api, output_api): | |
| 11 print "here" | |
| 12 """Checks if any new user action has been added.""" | |
| 13 if any('actions.xml' == input_api.os_path.basename(f) for f in | |
| 14 input_api.LocalPaths()): | |
| 15 # If actions.xml is already included in the changelist, the PRESUBMIT | |
| 16 # for actions.xml will do a more complete presubmit check. | |
| 17 return [] | |
| 18 | |
| 19 file_filter = lambda f: f.LocalPath().endswith(('.html')) | |
| 20 action_re = r'metric\s*=\s*"([^ ]*)"' | |
|
Alexei Svitkine (slow)
2014/11/11 20:36:41
Should we check for whitespace before the start of
gayane -on leave until 09-2017
2014/11/12 22:00:23
whitespaces or beginning of the line cases added t
| |
| 21 current_actions = None | |
| 22 for f in input_api.AffectedFiles(file_filter=file_filter): | |
| 23 for line_num, line in f.ChangedContents(): | |
| 24 match = input_api.re.search(action_re, line) | |
| 25 if match: | |
| 26 # Loads contents in tools/metrics/actions/actions.xml to memory. It's | |
| 27 # loaded only once. | |
| 28 if not current_actions: | |
| 29 with open('../../../tools/metrics/actions/actions.xml') as actions_f: | |
| 30 current_actions = actions_f.read() | |
| 31 # Search for the matched user action name in |current_actions|. | |
| 32 for action_name in match.groups(): | |
| 33 action = 'name="{0}"'.format(action_name) | |
| 34 if action not in current_actions: | |
| 35 return [output_api.PresubmitPromptWarning( | |
| 36 'File %s line %d: %s is missing in ' | |
| 37 'tools/metrics/actions/actions.xml. Please run ' | |
| 38 'tools/metrics/actions/extract_actions.py to update.' | |
| 39 % (f.LocalPath(), line_num, action_name))] | |
| 40 return [] | |
| 41 | |
| 42 def CheckChangeOnUpload(input_api, output_api): | |
| 43 return CheckUserActionUpdate(input_api, output_api) | |
| 44 | |
| 45 | |
| 46 def CheckChangeOnCommit(input_api, output_api): | |
| 47 return CheckUserActionUpdate(input_api, output_api) | |
| OLD | NEW |