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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 extra_maxlen = file_maxlen * 3 / 2 | 352 extra_maxlen = file_maxlen * 3 / 2 |
353 | 353 |
354 line_len = len(line) | 354 line_len = len(line) |
355 if line_len <= file_maxlen: | 355 if line_len <= file_maxlen: |
356 return True | 356 return True |
357 | 357 |
358 if line_len > extra_maxlen: | 358 if line_len > extra_maxlen: |
359 return False | 359 return False |
360 | 360 |
361 return ( | 361 return ( |
362 any((url in line) for url in ('http://', 'https://')) or | 362 any((url in line) for url in ('http://', 'https://', 'file://')) or |
M-A Ruel
2014/04/10 23:53:58
Keep ordered. Adding at the end of a list is not a
| |
363 input_api.re.match( | 363 input_api.re.match( |
364 r'.*[A-Za-z][A-Za-z_0-9]{%d,}.*' % long_symbol, line)) | 364 r'.*[A-Za-z][A-Za-z_0-9]{%d,}.*' % long_symbol, line)) |
365 | 365 |
366 def format_error(filename, line_num, line): | 366 def format_error(filename, line_num, line): |
367 return '%s, line %s, %s chars' % (filename, line_num, len(line)) | 367 return '%s, line %s, %s chars' % (filename, line_num, len(line)) |
368 | 368 |
369 errors = _FindNewViolationsOfRule(no_long_lines, input_api, | 369 errors = _FindNewViolationsOfRule(no_long_lines, input_api, |
370 source_file_filter, | 370 source_file_filter, |
371 error_formatter=format_error) | 371 error_formatter=format_error) |
372 if errors: | 372 if errors: |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1061 def CheckPatchFormatted(input_api, output_api): | 1061 def CheckPatchFormatted(input_api, output_api): |
1062 import git_cl | 1062 import git_cl |
1063 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()] | 1063 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()] |
1064 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True) | 1064 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True) |
1065 if code == 2: | 1065 if code == 2: |
1066 return [output_api.PresubmitPromptWarning( | 1066 return [output_api.PresubmitPromptWarning( |
1067 'Your patch is not formatted, please run git cl format.')] | 1067 'Your patch is not formatted, please run git cl format.')] |
1068 # As this is just a warning, ignore all other errors if the user | 1068 # As this is just a warning, ignore all other errors if the user |
1069 # happens to have a broken clang-format, doesn't use git, etc etc. | 1069 # happens to have a broken clang-format, doesn't use git, etc etc. |
1070 return [] | 1070 return [] |
OLD | NEW |