blob: 3e121f5bc59ce654560a6f0aaebc9bb66c9572d7 [file] [log] [blame]
henrike@webrtc.org390fcb72013-07-22 22:32:50 +00001# libjingle
2# Copyright 2013 Google Inc.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are met:
6#
7# 1. Redistributions of source code must retain the above copyright notice,
8# this list of conditions and the following disclaimer.
9# 2. Redistributions in binary form must reproduce the above copyright notice,
10# this list of conditions and the following disclaimer in the documentation
11# and/or other materials provided with the distribution.
12# 3. The name of the author may not be used to endorse or promote products
13# derived from this software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26def _LicenseHeader(input_api):
27 """Returns the license header regexp."""
fischman@webrtc.orgc3d93c62013-08-05 15:01:33 +000028 # Accept any year number from start of project to the current year
henrike@webrtc.org390fcb72013-07-22 22:32:50 +000029 current_year = int(input_api.time.strftime('%Y'))
fischman@webrtc.orgc3d93c62013-08-05 15:01:33 +000030 allowed_years = (str(s) for s in reversed(xrange(2004, current_year + 1)))
henrike@webrtc.org390fcb72013-07-22 22:32:50 +000031 years_re = '(' + '|'.join(allowed_years) + ')'
fischman@webrtc.org18f41b82014-05-23 17:27:18 +000032 years_re = '%s(--%s)?' % (years_re, years_re)
henrike@webrtc.org390fcb72013-07-22 22:32:50 +000033 license_header = (
34 r'.*? libjingle\n'
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:13 +000035 r'.*? Copyright %(year)s Google Inc\..*\n'
henrike@webrtc.org390fcb72013-07-22 22:32:50 +000036 r'.*?\n'
37 r'.*? Redistribution and use in source and binary forms, with or without'
38 r'\n'
39 r'.*? modification, are permitted provided that the following conditions '
40 r'are met:\n'
41 r'.*?\n'
42 r'.*? 1\. Redistributions of source code must retain the above copyright '
43 r'notice,\n'
44 r'.*? this list of conditions and the following disclaimer\.\n'
45 r'.*? 2\. Redistributions in binary form must reproduce the above '
46 r'copyright notice,\n'
47 r'.*? this list of conditions and the following disclaimer in the '
48 r'documentation\n'
49 r'.*? and/or other materials provided with the distribution\.\n'
50 r'.*? 3\. The name of the author may not be used to endorse or promote '
51 r'products\n'
52 r'.*? derived from this software without specific prior written '
53 r'permission\.\n'
54 r'.*?\n'
55 r'.*? THIS SOFTWARE IS PROVIDED BY THE AUTHOR \`\`AS IS\'\' AND ANY '
56 r'EXPRESS OR IMPLIED\n'
57 r'.*? WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES '
58 r'OF\n'
59 r'.*? MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE '
60 r'DISCLAIMED\. IN NO\n'
61 r'.*? EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, '
62 r'INCIDENTAL,\n'
63 r'.*? SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \(INCLUDING, '
64 r'BUT NOT LIMITED TO,\n'
65 r'.*? PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR '
66 r'PROFITS;\n'
67 r'.*? OR BUSINESS INTERRUPTION\) HOWEVER CAUSED AND ON ANY THEORY OF '
68 r'LIABILITY,\n'
69 r'.*? WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \(INCLUDING '
70 r'NEGLIGENCE OR\n'
71 r'.*? OTHERWISE\) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, '
72 r'EVEN IF\n'
73 r'.*? ADVISED OF THE POSSIBILITY OF SUCH DAMAGE\.\n'
74 ) % {
75 'year': years_re,
76 }
77 return license_header
78
79def _CommonChecks(input_api, output_api):
80 """Checks common to both upload and commit."""
81 results = []
82 results.extend(input_api.canned_checks.CheckLicense(
83 input_api, output_api, _LicenseHeader(input_api)))
henrike@webrtc.org390fcb72013-07-22 22:32:50 +000084 return results
85
86def CheckChangeOnUpload(input_api, output_api):
87 results = []
88 results.extend(_CommonChecks(input_api, output_api))
89 return results
90
91def CheckChangeOnCommit(input_api, output_api):
92 results = []
93 results.extend(_CommonChecks(input_api, output_api))
94 return results