blob: 44d827a17e69d9a16e0b695513ca0b34bb9fd602 [file] [log] [blame]
# Copyright 2013 The Swarming Authors. All rights reserved.
# Use of this source code is governed by the Apache v2.0 license that can be
# found in the LICENSE file.
"""Top-level presubmit script for swarming.
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
details on the presubmit API built into gcl.
"""
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(xrange(2011, current_year + 1)))
years_re = '(' + '|'.join(allowed_years) + ')'
license_header = (
r'.*? Copyright %(year)s The Swarming Authors\. '
r'All rights reserved\.\n'
r'.*? Use of this source code is governed by the Apache v2\.0 license '
r'that can be\n'
r'.*? found in the LICENSE file\.(?: \*/)?\n'
) % {
'year': years_re,
}
return license_header
def CommonChecks(input_api, output_api):
excluded = [
r'.*_pb2\.py$',
r'.*-build\.(js|html)$',
]
return input_api.canned_checks.PanProjectChecks(
input_api, output_api,
excluded_paths=excluded,
owners_check=False,
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)