blob: 33bdab3e065bfc8574dc25963258d9ea71f5a491 [file] [log] [blame]
andrew@webrtc.org2442de12012-01-23 17:45:41 +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.
niklase@google.comda159d62011-05-30 11:51:34 +00008
andrew@webrtc.org53df1362012-01-26 21:24:23 +00009def _LicenseHeader(input_api):
10 """Returns the license header regexp."""
11 license_header = (
andrew@webrtc.org2442de12012-01-23 17:45:41 +000012 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 }
andrew@webrtc.org53df1362012-01-26 21:24:23 +000024 return license_header
andrew@webrtc.org2442de12012-01-23 17:45:41 +000025
andrew@webrtc.org53df1362012-01-26 21:24:23 +000026def _CommonChecks(input_api, output_api):
27 """Checks common to both upload and commit."""
niklase@google.comda159d62011-05-30 11:51:34 +000028 results = []
andrew@webrtc.org2442de12012-01-23 17:45:41 +000029 results.extend(input_api.canned_checks.CheckLongLines(
andrew@webrtc.org53df1362012-01-26 21:24:23 +000030 input_api, output_api))
andrew@webrtc.org2442de12012-01-23 17:45:41 +000031 results.extend(input_api.canned_checks.CheckChangeHasNoTabs(
32 input_api, output_api))
andrew@webrtc.org53df1362012-01-26 21:24:23 +000033 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))
andrew@webrtc.org2442de12012-01-23 17:45:41 +000037 results.extend(input_api.canned_checks.CheckLicense(
andrew@webrtc.org53df1362012-01-26 21:24:23 +000038 input_api, output_api, _LicenseHeader(input_api)))
39 return results
andrew@webrtc.org2442de12012-01-23 17:45:41 +000040
andrew@webrtc.org53df1362012-01-26 21:24:23 +000041def CheckChangeOnUpload(input_api, output_api):
42 results = []
43 results.extend(_CommonChecks(input_api, output_api))
niklase@google.comda159d62011-05-30 11:51:34 +000044 return results
45
andrew@webrtc.org2442de12012-01-23 17:45:41 +000046def CheckChangeOnCommit(input_api, output_api):
niklase@google.com1198db92011-06-09 07:07:24 +000047 results = []
andrew@webrtc.org53df1362012-01-26 21:24:23 +000048 results.extend(_CommonChecks(input_api, output_api))
niklase@google.com1198db92011-06-09 07:07:24 +000049 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api))
andrew@webrtc.org53df1362012-01-26 21:24:23 +000050 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))
niklase@google.com1198db92011-06-09 07:07:24 +000054 return results