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.
10 r".*? Copyright \(c\) 20\d\d The Chromium Authors\. All rights reserved\."
12 r".*? Use of this source code is governed by a BSD-style license that can "
14 r".*? found in the LICENSE file\."
19 def _CommonChecks(input_api, output_api):
21 results.extend(input_api.canned_checks.PanProjectChecks(
22 input_api, output_api, excluded_paths=_EXCLUDED_PATHS))
24 src_dir = os.path.join(input_api.change.RepositoryRoot(), "src")
26 def IsResource(maybe_resource):
27 f = maybe_resource.AbsoluteLocalPath()
28 if not f.endswith(('.css', '.html', '.js')):
32 from web_dev_style import css_checker, js_checker
33 results.extend(css_checker.CSSChecker(input_api, output_api,
34 file_filter=IsResource).RunChecks())
35 results.extend(js_checker.JSChecker(input_api, output_api,
36 file_filter=IsResource).RunChecks())
38 from build import check_gyp
39 gyp_result = check_gyp.GypCheck()
40 if len(gyp_result) > 0:
41 results.extend([output_api.PresubmitError(gyp_result)])
43 from build import check_grit
44 grit_result = check_grit.GritCheck()
45 if len(grit_result) > 0:
46 results.extend([output_api.PresubmitError(grit_result)])
48 black_list = input_api.DEFAULT_BLACK_LIST
49 sources = lambda x: input_api.FilterSourceFile(x, black_list=black_list)
50 results.extend(input_api.canned_checks.CheckLicense(
51 input_api, output_api, _LICENSE_HEADER,
52 source_file_filter=sources))
56 def GetPathsToPrepend(input_api):
57 web_dev_style_path = input_api.os_path.join(
58 input_api.change.RepositoryRoot(),
61 return [input_api.PresubmitLocalPath(), web_dev_style_path]
64 def RunWithPrependedPath(prepended_path, fn, *args):
69 sys.path = prepended_path + old_path
75 def CheckChangeOnUpload(input_api, output_api):
78 results.extend(_CommonChecks(input_api, output_api))
80 return RunWithPrependedPath(GetPathsToPrepend(input_api), go)
83 def CheckChangeOnCommit(input_api, output_api):
86 results.extend(_CommonChecks(input_api, output_api))
88 return RunWithPrependedPath(GetPathsToPrepend(input_api), go)