Chromium Code Reviews| Index: PRESUBMIT.py |
| diff --git a/PRESUBMIT.py b/PRESUBMIT.py |
| index fce336da65048046a452911b8d9243f5eadbce7f..66aa5ea2e8312fb18b71a8c14e2d7f5797324ab6 100644 |
| --- a/PRESUBMIT.py |
| +++ b/PRESUBMIT.py |
| @@ -1,6 +1,16 @@ |
| -# Copyright 2015 The LUCI Authors. All rights reserved. |
| -# Use of this source code is governed under the Apache License, Version 2.0 |
| -# that can be found in the LICENSE file. |
| +# Copyright 2017 The LUCI Authors. |
| +# |
| +# Licensed under the Apache License, Version 2.0 (the "License"); |
| +# you may not use this file except in compliance with the License. |
| +# You may obtain a copy of the License at |
| +# |
| +# http://www.apache.org/licenses/LICENSE-2.0 |
| +# |
| +# Unless required by applicable law or agreed to in writing, software |
| +# distributed under the License is distributed on an "AS IS" BASIS, |
| +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| +# See the License for the specific language governing permissions and |
| +# limitations under the License. |
| """Top-level presubmit script. |
| @@ -9,6 +19,7 @@ details on the presubmit API built into depot_tools. |
| """ |
| import os |
| +import re |
| import sys |
| @@ -65,26 +76,38 @@ def WebChecks(input_api, output_api): |
| 'presubmit', |
| ], |
| kwargs={}, |
| - message=output_api.PresubmitError, |
| + message=error_type, |
| )]) |
| return output |
| +COPYRIGHT_TEMPLATE = """ |
| +Copyright YEARPATTERN The LUCI Authors. |
| + |
| +Licensed under the Apache License, Version 2.0 (the "License"); |
| +you may not use this file except in compliance with the License. |
| +You may obtain a copy of the License at |
| + |
| + http://www.apache.org/licenses/LICENSE-2.0 |
| + |
| +Unless required by applicable law or agreed to in writing, software |
| +distributed under the License is distributed on an "AS IS" BASIS, |
| +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| +See the License for the specific language governing permissions and |
| +limitations under the License. |
| +""".strip() |
| + |
| 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 LUCI Authors\. ' |
| - r'All rights reserved\.\n' |
| - r'.*? Use of this source code is governed under the Apache License, ' |
| - r'Version 2\.0\n' |
| - r'.*? that can be found in the LICENSE file\.(?: \*/)?\n' |
| - ) % { |
| - 'year': years_re, |
| - } |
| - return license_header |
| + lines = [ |
| + ('.*? ' + re.escape(line)) if line else '.*?' |
| + for line in COPYRIGHT_TEMPLATE.splitlines() |
| + ] |
| + lines[0] = lines[0].replace('YEARPATTERN', years_re) |
|
Ryan Tseng
2017/07/15 01:08:23
lol
|
| + return '\n'.join(lines) + '(?: \*/)?\n' |
| def source_file_filter(input_api): |