OLD | NEW |
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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 A list of warning or error objects. | 949 A list of warning or error objects. |
950 """ | 950 """ |
951 excluded_paths = tuple(excluded_paths or []) | 951 excluded_paths = tuple(excluded_paths or []) |
952 text_files = tuple(text_files or ( | 952 text_files = tuple(text_files or ( |
953 r'.+\.txt$', | 953 r'.+\.txt$', |
954 r'.+\.json$', | 954 r'.+\.json$', |
955 )) | 955 )) |
956 project_name = project_name or 'Chromium' | 956 project_name = project_name or 'Chromium' |
957 | 957 |
958 # Accept any year number from 2006 to the current year, or the special | 958 # Accept any year number from 2006 to the current year, or the special |
959 # 2006-2008 string used on the oldest files. 2006-2008 is deprecated, but | 959 # 2006-20xx string used on the oldest files. 2006-20xx is deprecated, but |
960 # tolerate it until it's removed from all files. | 960 # tolerated on old files. |
961 current_year = int(input_api.time.strftime('%Y')) | 961 current_year = int(input_api.time.strftime('%Y')) |
962 allowed_years = (str(s) for s in reversed(xrange(2006, current_year + 1))) | 962 allowed_years = (str(s) for s in reversed(xrange(2006, current_year + 1))) |
963 years_re = '(' + '|'.join(allowed_years) + '|2006-2008)' | 963 years_re = '(' + '|'.join(allowed_years) + '|2006-2008|2006-2009|2006-2010)' |
964 | 964 |
965 # The (c) is deprecated, but tolerate it until it's removed from all files. | 965 # The (c) is deprecated, but tolerate it until it's removed from all files. |
966 license_header = license_header or ( | 966 license_header = license_header or ( |
967 r'.*? Copyright (\(c\) )?%(year)s The %(project)s Authors\. ' | 967 r'.*? Copyright (\(c\) )?%(year)s The %(project)s Authors\. ' |
968 r'All rights reserved\.\n' | 968 r'All rights reserved\.\n' |
969 r'.*? Use of this source code is governed by a BSD-style license that ' | 969 r'.*? Use of this source code is governed by a BSD-style license that ' |
970 r'can be\n' | 970 r'can be\n' |
971 r'.*? found in the LICENSE file\.(?: \*/)?\n' | 971 r'.*? found in the LICENSE file\.(?: \*/)?\n' |
972 ) % { | 972 ) % { |
973 'year': years_re, | 973 'year': years_re, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 def CheckPatchFormatted(input_api, output_api): | 1046 def CheckPatchFormatted(input_api, output_api): |
1047 import git_cl | 1047 import git_cl |
1048 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()] | 1048 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()] |
1049 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True) | 1049 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True) |
1050 if code == 2: | 1050 if code == 2: |
1051 return [output_api.PresubmitPromptWarning( | 1051 return [output_api.PresubmitPromptWarning( |
1052 'Your patch is not formatted, please run git cl format.')] | 1052 'Your patch is not formatted, please run git cl format.')] |
1053 # As this is just a warning, ignore all other errors if the user | 1053 # As this is just a warning, ignore all other errors if the user |
1054 # happens to have a broken clang-format, doesn't use git, etc etc. | 1054 # happens to have a broken clang-format, doesn't use git, etc etc. |
1055 return [] | 1055 return [] |
OLD | NEW |