Chromium Code Reviews| Index: chrome/app/policy/PRESUBMIT.py |
| diff --git a/chrome/app/policy/PRESUBMIT.py b/chrome/app/policy/PRESUBMIT.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5d4f42fae2c0b936714684187833aea90134b15f |
| --- /dev/null |
| +++ b/chrome/app/policy/PRESUBMIT.py |
| @@ -0,0 +1,38 @@ |
| +# Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +# If this presubmit check fails or misbehaves, please complain to |
| +# gfeher@chromium.org or jkummerow@chromium.org. |
| + |
| +import sys |
| +import traceback |
|
M-A Ruel
2011/01/18 16:06:23
pelase remove this import, it's not used.
Jakob Kummerow
2011/01/18 16:33:54
Done.
(Leftover from an earlier version. Should've
|
| + |
| + |
| +def _CommonChecks(input_api, output_api): |
| + filename = 'policy_templates.json' |
| + results = [] |
| + old_sys_path = sys.path |
| + try: |
| + sys.path = [input_api.PresubmitLocalPath()] + sys.path |
| + for f in input_api.AffectedFiles(): |
|
M-A Ruel
2011/01/18 16:06:23
nit: Sorry for the round-trips but what about chan
Jakob Kummerow
2011/01/18 16:33:54
No problem at all. I'm always happy to learn how t
|
| + if (f.AbsoluteLocalPath() == |
| + input_api.os_path.join(input_api.PresubmitLocalPath(), filename)): |
| + # Optimization: only load this when it's needed. |
| + import syntax_check_policy_template_json |
| + checker = syntax_check_policy_template_json.PolicyTemplateChecker() |
| + result = checker.Run([], f.AbsoluteLocalPath()) |
| + if result > 0: |
| + results.append(output_api.PresubmitError( |
| + 'Syntax error(s) in file:', [f])) |
| + finally: |
| + sys.path = old_sys_path |
| + return results |
| + |
| + |
| +def CheckChangeOnUpload(input_api, output_api): |
| + return _CommonChecks(input_api, output_api) |
| + |
| + |
| +def CheckChangeOnCommit(input_api, output_api): |
| + return _CommonChecks(input_api, output_api) |