Adding CheckChangeHasOnlyOneEol to upload and commit presubmit checks
[platform/upstream/libSkiaSharp.git] / PRESUBMIT.py
1 # Copyright (c) 2013 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
6 """Top-level presubmit script for Skia.
7
8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
9 for more details about the presubmit API built into gcl.
10 """
11
12 def _CommonChecks(input_api, output_api):
13   """Presubmit checks common to upload and commit."""
14   results = []
15   sources = lambda x: (x.LocalPath().endswith('.h') or
16                        x.LocalPath().endswith('.gypi') or
17                        x.LocalPath().endswith('.gyp') or
18                        x.LocalPath().endswith('.py') or
19                        x.LocalPath().endswith('.sh') or
20                        x.LocalPath().endswith('.cpp'))
21   results.extend(
22       input_api.canned_checks.CheckChangeHasOnlyOneEol(
23           input_api, output_api, source_file_filter=sources))
24   return results
25
26
27 def CheckChangeOnUpload(input_api, output_api):
28   """Presubmit checks for the change on upload.
29
30   The following are the presubmit checks:
31   * Check change has one and only one EOL.
32   """
33   results = []
34   results.extend(_CommonChecks(input_api, output_api))
35   return results
36
37
38 def CheckChangeOnCommit(input_api, output_api):
39   """Presubmit checks for the change on commit.
40
41   The following are the presubmit checks:
42   * Check change has one and only one EOL.
43   * Ensures that the Skia tree is not closed in
44     http://skia-tree-status.appspot.com/
45   """
46   results = []
47   results.extend(_CommonChecks(input_api, output_api))
48   results.extend(
49       input_api.canned_checks.CheckTreeIsOpen(
50           input_api, output_api, json_url=(
51               'http://skia-tree-status.appspot.com/banner-status?format=json')))
52   return results