7373]
7474
7575
76- def CheckChangeOnUpload (input_api , output_api ):
77- report = []
78- report .extend (input_api .canned_checks .PanProjectChecks (
79- input_api , output_api ))
80- return report
81-
82-
83- def CheckChangeOnCommit (input_api , output_api ):
84- report = []
85-
76+ def _LicenseHeader (input_api ):
8677 # Accept any year number from 2009 to the current year.
8778 current_year = int (input_api .time .strftime ('%Y' ))
8879 allowed_years = (str (s ) for s in reversed (xrange (2009 , current_year + 1 )))
80+
8981 years_re = '(' + '|' .join (allowed_years ) + ')'
9082
9183 # The (c) is deprecated, but tolerate it until it's removed from all files.
92- license = (
84+ return (
9385 r'.*? Copyright (\(c\) )?%(year)s Google Inc\. All rights reserved\.\n'
9486 r'.*? Use of this source code is governed by a BSD-style license that '
9587 r'can be\n'
@@ -98,8 +90,18 @@ def CheckChangeOnCommit(input_api, output_api):
9890 'year' : years_re ,
9991 }
10092
93+ def CheckChangeOnUpload (input_api , output_api ):
94+ report = []
95+ report .extend (input_api .canned_checks .PanProjectChecks (
96+ input_api , output_api , license_header = _LicenseHeader (input_api )))
97+ return report
98+
99+
100+ def CheckChangeOnCommit (input_api , output_api ):
101+ report = []
102+
101103 report .extend (input_api .canned_checks .PanProjectChecks (
102- input_api , output_api , license_header = license ))
104+ input_api , output_api , license_header = _LicenseHeader ( input_api ) ))
103105 report .extend (input_api .canned_checks .CheckTreeIsOpen (
104106 input_api , output_api ,
105107 'http://gyp-status.appspot.com/status' ,
0 commit comments