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

Side by Side Diff: chrome/browser/resources/PRESUBMIT.py

Issue 9323016: [WebUI] Add some presubmit checks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove debug messages Created 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2012 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 """Presubmit script for Chromium WebUI resources.
6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl/git cl, and see
9 http://www.chromium.org/developers/web-development-style-guide for the rules
10 we're checking against here.
11 """
12
13
14 def CheckChangeOnUpload(input_api, output_api):
15 return _CommonChecks(input_api, output_api)
16
17
18 def CheckChangeOnCommit(input_api, output_api):
19 return _CommonChecks(input_api, output_api)
20
21
22 def _CommonChecks(input_api, output_api):
23 """Checks common to both upload and commit."""
24 results = []
25 resources = input_api.PresubmitLocalPath()
26
27 path = input_api.os_path
28 presubmit = path.join(resources, 'PRESUBMIT.py')
29 if presubmit in [f.AbsoluteLocalPath() for f in input_api.AffectedFiles()]:
M-A Ruel 2012/02/09 22:14:14 if presubmit in (f.AbsoluteLocalPath() for f in in
Dan Beam 2012/02/14 17:02:01 Done. (list -> tuple)
M-A Ruel 2012/02/14 17:15:19 You are confusing tuple and generators. This is a
Dan Beam 2012/02/14 17:48:46 See updated code (and tell me if it's still wrong)
30 tests = [path.join(resources, 'test_presubmit.py')]
31 results.extend(
32 input_api.canned_checks.RunUnitTests(input_api, output_api, tests))
33
34 import sys
35 old_sys_path = sys.path
36 try:
37 from web_dev_style import css_checker
38 except ImportError:
39 sys.path.append(resources)
M-A Ruel 2012/02/09 22:14:14 sys.path.insert(0, resources)
Dan Beam 2012/02/14 17:02:01 Done.
40 from web_dev_style import css_checker
41 finally:
42 sys.path = old_sys_path
43
44 # TODO(dbeam): Remove this filter eventually when ready.
45 def file_filter(affected_file):
46 dirs = (path.join(resources, 'ntp4'), path.join(resources, 'options2'))
47 f = affected_file.AbsoluteLocalPath()
48 return (f.startswith(dirs) and f.endswith('.css'))
49
50 results.extend(css_checker.CSSChecker(input_api, output_api,
51 file_filter=file_filter).RunChecks())
52 return results
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/test_presubmit.py » ('j') | chrome/browser/resources/test_presubmit.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698