mirrored from https://chromium.googlesource.com/infra/luci/luci-py
-
Notifications
You must be signed in to change notification settings - Fork 36
/
PRESUBMIT.py
56 lines (43 loc) · 1.73 KB
/
PRESUBMIT.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright 2013 The LUCI Authors. All rights reserved.
# Use of this source code is governed under the Apache License, Version 2.0
# that can be found in the LICENSE file.
"""Top-level presubmit script for LUCI.
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
details on the presubmit API built into gclient.
"""
USE_PYTHON3 = True
def header(input_api):
"""Returns the expected license header regexp for this project."""
current_year = int(input_api.time.strftime('%Y'))
allowed_years = (str(s) for s in reversed(range(2011, current_year + 1)))
years_re = '(' + '|'.join(allowed_years) + ')'
license_header = (
r'.*? Copyright %(year)s The LUCI Authors\. '
r'All rights reserved\.\n'
r'.*? Use of this source code is governed under the Apache License, '
r'Version 2\.0\n'
r'.*? that can be found in the LICENSE file\.(?: \*/)?\n') % {
'year': years_re,
}
return license_header
def CommonChecks(input_api, output_api):
excluded = [
r'.+-build\.(js|html)$',
r'.+/build/.+(js|html)$',
r'.+/dist/.+(js|html|css)$',
r'/test',
r'.+_pb2\.py$',
r'.*third_party.*',
# This is a symlink to third_party, so it shouldn't be checked.
r'appengine/swarming/bqh\.py$',
]
return (input_api.canned_checks.CheckPatchFormatted(input_api, output_api) +
input_api.canned_checks.PanProjectChecks(
input_api,
output_api,
excluded_paths=excluded,
license_header=header(input_api)))
def CheckChangeOnUpload(input_api, output_api):
return CommonChecks(input_api, output_api)
def CheckChangeOnCommit(input_api, output_api):
return CommonChecks(input_api, output_api)