Chromium Code Reviews| Index: PRESUBMIT.py |
| diff --git a/PRESUBMIT.py b/PRESUBMIT.py |
| index ae5a2183162c81026e8e382e6792b75fe362cc8c..d2e8ee6951cc5cf2c443d3e8efe1d7d03ac069c6 100644 |
| --- a/PRESUBMIT.py |
| +++ b/PRESUBMIT.py |
| @@ -118,6 +118,38 @@ def _IfDefChecks(input_api, output_api): |
| return results |
| +def _CopyrightChecks(input_api, output_api, source_file_filter=None): |
| + results = [] |
| + year_pattern = r'\d{4}' |
| + year_range_pattern = r'%s(-%s)?' % (year_pattern, year_pattern) |
| + years_pattern = r'%s(,%s)*,?' % (year_range_pattern, year_range_pattern) |
| + copyright_pattern = ( |
| + r'Copyright (\([cC]\) )?%s %s' % (years_pattern, '%s')) |
| + owners = [ |
| + 'ARM Ltd.', |
| + 'Code Aurora Forum. All rights reserved.', |
| + 'Google,? Inc\.?( All rights reserved.)?', |
| + 'Intel Inc.', |
| + 'Lua.org, PUC-Rio', |
| + 'Skia', |
| + 'The Android Open Source Project', |
| + 'The Chromium Authors. All rights reserved.', |
| + 'The Native Client Authors. All rights reserved.', |
|
borenet
2015/03/23 14:38:05
I just pulled these from existing copyright notice
mtklein
2015/03/23 14:49:50
Let's both exclude third_party ('Lua.org, PUC-Rio'
borenet
2015/03/23 17:20:35
Done.
|
| + ] |
| + |
| + for affected_file in input_api.AffectedSourceFiles(source_file_filter): |
| + contents = input_api.ReadFile(affected_file, 'rb') |
| + found = False |
| + for owner in owners: |
| + if re.search(copyright_pattern % owner, contents): |
| + found = True |
| + break |
| + if not found: |
| + results.append(output_api.PresubmitError( |
| + '%s is missing a correct copyright header.' % affected_file)) |
| + return results |
| + |
| + |
| def _CommonChecks(input_api, output_api): |
| """Presubmit checks common to upload and commit.""" |
| results = [] |
| @@ -132,6 +164,8 @@ def _CommonChecks(input_api, output_api): |
| input_api, output_api, source_file_filter=sources)) |
| results.extend(_PythonChecks(input_api, output_api)) |
| results.extend(_IfDefChecks(input_api, output_api)) |
| + results.extend(_CopyrightChecks(input_api, output_api, |
| + source_file_filter=sources)) |
| return results |