Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(787)

Side by Side Diff: presubmit_canned_checks.py

Issue 10824191: New copyright boilerplate policy for presubmit: don't require the current year (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Generic presubmit checks that can be reused by other presubmit checks.""" 5 """Generic presubmit checks that can be reused by other presubmit checks."""
6 6
7 import os as _os 7 import os as _os
8 _HERE = _os.path.dirname(_os.path.abspath(__file__)) 8 _HERE = _os.path.dirname(_os.path.abspath(__file__))
9 9
10 10
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 project_name: What is the name of the project as it appears in the license. 875 project_name: What is the name of the project as it appears in the license.
876 Returns: 876 Returns:
877 A list of warning or error objects. 877 A list of warning or error objects.
878 """ 878 """
879 excluded_paths = tuple(excluded_paths or []) 879 excluded_paths = tuple(excluded_paths or [])
880 text_files = tuple(text_files or ( 880 text_files = tuple(text_files or (
881 r'.+\.txt$', 881 r'.+\.txt$',
882 r'.+\.json$', 882 r'.+\.json$',
883 )) 883 ))
884 project_name = project_name or 'Chromium' 884 project_name = project_name or 'Chromium'
885
886 # Accept any year number from 2006 to the current year, or the special
887 # 2006-2008 string used on the oldest files. 2006-2008 is deprecated, but
888 # tolerate it until it's removed from all files.
889 current_year = int(input_api.time.strftime('%Y'))
890 allowed_years = (str(s) for s in reversed(xrange(2006, current_year + 1)))
891 years_re = '(' + '|'.join(allowed_years) + '|2006-2008)'
892
893 # The (c) is deprecated, but tolerate it until it's removed from all files.
885 license_header = license_header or ( 894 license_header = license_header or (
886 r'.*? Copyright \(c\) %(year)s The %(project)s Authors\. ' 895 r'.*? Copyright (\(c\) )?%(year)s The %(project)s Authors\. '
887 r'All rights reserved\.\n' 896 r'All rights reserved\.\n'
888 r'.*? Use of this source code is governed by a BSD-style license that ' 897 r'.*? Use of this source code is governed by a BSD-style license that '
889 r'can be\n' 898 r'can be\n'
890 r'.*? found in the LICENSE file\.(?: \*/)?\n' 899 r'.*? found in the LICENSE file\.(?: \*/)?\n'
891 ) % { 900 ) % {
892 'year': input_api.time.strftime('%Y'), 901 'year': years_re,
893 'project': project_name, 902 'project': project_name,
894 } 903 }
895 904
896 results = [] 905 results = []
897 # This code loads the default black list (e.g. third_party, experimental, etc) 906 # This code loads the default black list (e.g. third_party, experimental, etc)
898 # and add our black list (breakpad, skia and v8 are still not following 907 # and add our black list (breakpad, skia and v8 are still not following
899 # google style and are not really living this repository). 908 # google style and are not really living this repository).
900 # See presubmit_support.py InputApi.FilterSourceFile for the (simple) usage. 909 # See presubmit_support.py InputApi.FilterSourceFile for the (simple) usage.
901 black_list = input_api.DEFAULT_BLACK_LIST + excluded_paths 910 black_list = input_api.DEFAULT_BLACK_LIST + excluded_paths
902 white_list = input_api.DEFAULT_WHITE_LIST + text_files 911 white_list = input_api.DEFAULT_WHITE_LIST + text_files
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( 954 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes(
946 input_api, output_api)) 955 input_api, output_api))
947 snapshot("checking license") 956 snapshot("checking license")
948 results.extend(input_api.canned_checks.CheckLicense( 957 results.extend(input_api.canned_checks.CheckLicense(
949 input_api, output_api, license_header, source_file_filter=sources)) 958 input_api, output_api, license_header, source_file_filter=sources))
950 snapshot("checking was uploaded") 959 snapshot("checking was uploaded")
951 results.extend(input_api.canned_checks.CheckChangeWasUploaded( 960 results.extend(input_api.canned_checks.CheckChangeWasUploaded(
952 input_api, output_api)) 961 input_api, output_api))
953 snapshot("done") 962 snapshot("done")
954 return results 963 return results
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698