blob: 5e2faaf0ab615f4ece65ae281b00b77d4ac2c59a [file] [log] [blame]
kjellander@webrtc.orgde2a76f2012-03-27 15:57:30 +00001# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
2#
3# Use of this source code is governed by a BSD-style license
4# that can be found in the LICENSE file in the root of the source
5# tree. An additional intellectual property rights grant can be found
6# in the file PATENTS. All contributing project authors may
7# be found in the AUTHORS file in the root of the source tree.
8
9def _LicenseHeader(input_api):
10 """Returns the license header regexp."""
11 license_header = (
12 r'.*? Copyright \(c\) %(year)s The WebRTC project authors\. '
13 r'All Rights Reserved\.\n'
14 r'.*?\n'
15 r'.*? Use of this source code is governed by a BSD-style license\n'
16 r'.*? that can be found in the LICENSE file in the root of the source\n'
17 r'.*? tree\. An additional intellectual property rights grant can be '
18 r'found\n'
19 r'.*? in the file PATENTS\. All contributing project authors may\n'
20 r'.*? be found in the AUTHORS file in the root of the source tree\.\n'
21 ) % {
22 'year': input_api.time.strftime('%Y'),
23 }
24 return license_header
25
26def _CommonChecks(input_api, output_api):
27 """Checks common to both upload and commit."""
28 results = []
29 results.extend(input_api.canned_checks.CheckLongLines(
30 input_api, output_api))
31 results.extend(input_api.canned_checks.CheckChangeHasNoTabs(
32 input_api, output_api))
33 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace(
34 input_api, output_api))
35 results.extend(input_api.canned_checks.CheckChangeTodoHasOwner(
36 input_api, output_api))
37 results.extend(input_api.canned_checks.CheckLicense(
38 input_api, output_api, _LicenseHeader(input_api)))
39 return results
40
41def CheckChangeOnUpload(input_api, output_api):
42 results = []
43 results.extend(_CommonChecks(input_api, output_api))
44 return results
45
46def CheckChangeOnCommit(input_api, output_api):
47 results = []
48 results.extend(_CommonChecks(input_api, output_api))
49 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api))
50 results.extend(input_api.canned_checks.CheckChangeWasUploaded(
51 input_api, output_api))
52 results.extend(input_api.canned_checks.CheckChangeHasDescription(
53 input_api, output_api))
54 results.extend(input_api.canned_checks.CheckChangeHasBugField(
55 input_api, output_api))
56 results.extend(input_api.canned_checks.CheckChangeHasTestField(
57 input_api, output_api))
58 return results