| 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 | 357 |
| 358 if line_len > extra_maxlen: | 358 if line_len > extra_maxlen: |
| 359 return False | 359 return False |
| 360 | 360 |
| 361 if any((url in line) for url in ('file://', 'http://', 'https://')): | 361 if any((url in line) for url in ('file://', 'http://', 'https://')): |
| 362 return True | 362 return True |
| 363 | 363 |
| 364 if 'url(' in line and file_extension == 'css': | 364 if 'url(' in line and file_extension == 'css': |
| 365 return True | 365 return True |
| 366 | 366 |
| 367 if '<include' in line and file_extension in ('css', 'html', 'js'): |
| 368 return True |
| 369 |
| 367 return input_api.re.match( | 370 return input_api.re.match( |
| 368 r'.*[A-Za-z][A-Za-z_0-9]{%d,}.*' % long_symbol, line) | 371 r'.*[A-Za-z][A-Za-z_0-9]{%d,}.*' % long_symbol, line) |
| 369 | 372 |
| 370 def format_error(filename, line_num, line): | 373 def format_error(filename, line_num, line): |
| 371 return '%s, line %s, %s chars' % (filename, line_num, len(line)) | 374 return '%s, line %s, %s chars' % (filename, line_num, len(line)) |
| 372 | 375 |
| 373 errors = _FindNewViolationsOfRule(no_long_lines, input_api, | 376 errors = _FindNewViolationsOfRule(no_long_lines, input_api, |
| 374 source_file_filter, | 377 source_file_filter, |
| 375 error_formatter=format_error) | 378 error_formatter=format_error) |
| 376 if errors: | 379 if errors: |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 def CheckPatchFormatted(input_api, output_api): | 1101 def CheckPatchFormatted(input_api, output_api): |
| 1099 import git_cl | 1102 import git_cl |
| 1100 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()] | 1103 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()] |
| 1101 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True) | 1104 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True) |
| 1102 if code == 2: | 1105 if code == 2: |
| 1103 return [output_api.PresubmitPromptWarning( | 1106 return [output_api.PresubmitPromptWarning( |
| 1104 'Your patch is not formatted, please run git cl format.')] | 1107 'Your patch is not formatted, please run git cl format.')] |
| 1105 # As this is just a warning, ignore all other errors if the user | 1108 # As this is just a warning, ignore all other errors if the user |
| 1106 # happens to have a broken clang-format, doesn't use git, etc etc. | 1109 # happens to have a broken clang-format, doesn't use git, etc etc. |
| 1107 return [] | 1110 return [] |
| OLD | NEW |