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 """Top-level presubmit script for Chromium. | 5 """Top-level presubmit script for Chromium. |
6 | 6 |
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
8 for more details about the presubmit API built into gcl. | 8 for more details about the presubmit API built into gcl. |
9 """ | 9 """ |
10 | 10 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 lines = input_api.ReadFile(f).splitlines() | 216 lines = input_api.ReadFile(f).splitlines() |
217 line_number = 0 | 217 line_number = 0 |
218 for line in lines: | 218 for line in lines: |
219 if (inclusion_pattern.search(line) and | 219 if (inclusion_pattern.search(line) and |
220 not exclusion_pattern.search(line)): | 220 not exclusion_pattern.search(line)): |
221 problems.append( | 221 problems.append( |
222 '%s:%d\n %s' % (local_path, line_number, line.strip())) | 222 '%s:%d\n %s' % (local_path, line_number, line.strip())) |
223 line_number += 1 | 223 line_number += 1 |
224 | 224 |
225 if problems: | 225 if problems: |
226 if not input_api.is_committing: | 226 # We don't warn on commit, to avoid stopping commits going through CQ. |
M-A Ruel
2013/03/26 18:05:00
I think you can remove all the comments too, here
Wez
2013/03/26 20:08:02
Done.
| |
227 return [output_api.PresubmitPromptWarning(_TEST_ONLY_WARNING, problems)] | 227 return [output_api.PresubmitPromptOrNotify(_TEST_ONLY_WARNING, problems)] |
228 else: | |
229 # We don't warn on commit, to avoid stopping commits going through CQ. | |
230 return [output_api.PresubmitNotifyResult(_TEST_ONLY_WARNING, problems)] | |
231 else: | 228 else: |
232 return [] | 229 return [] |
233 | 230 |
234 | 231 |
235 def _CheckNoIOStreamInHeaders(input_api, output_api): | 232 def _CheckNoIOStreamInHeaders(input_api, output_api): |
236 """Checks to make sure no .h files include <iostream>.""" | 233 """Checks to make sure no .h files include <iostream>.""" |
237 files = [] | 234 files = [] |
238 pattern = input_api.re.compile(r'^#include\s*<iostream>', | 235 pattern = input_api.re.compile(r'^#include\s*<iostream>', |
239 input_api.re.MULTILINE) | 236 input_api.re.MULTILINE) |
240 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): | 237 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 error_descriptions.append(description_with_path) | 430 error_descriptions.append(description_with_path) |
434 else: | 431 else: |
435 warning_descriptions.append(description_with_path) | 432 warning_descriptions.append(description_with_path) |
436 | 433 |
437 results = [] | 434 results = [] |
438 if error_descriptions: | 435 if error_descriptions: |
439 results.append(output_api.PresubmitError( | 436 results.append(output_api.PresubmitError( |
440 'You added one or more #includes that violate checkdeps rules.', | 437 'You added one or more #includes that violate checkdeps rules.', |
441 error_descriptions)) | 438 error_descriptions)) |
442 if warning_descriptions: | 439 if warning_descriptions: |
443 if not input_api.is_committing: | 440 # We don't want to block use of the CQ when there is a warning |
444 warning_factory = output_api.PresubmitPromptWarning | 441 # of this kind, so we only show a message when committing. |
445 else: | 442 results.append(output_api.PresubmitPromptOrNotify( |
446 # We don't want to block use of the CQ when there is a warning | |
447 # of this kind, so we only show a message when committing. | |
448 warning_factory = output_api.PresubmitNotifyResult | |
449 results.append(warning_factory( | |
450 'You added one or more #includes of files that are temporarily\n' | 443 'You added one or more #includes of files that are temporarily\n' |
451 'allowed but being removed. Can you avoid introducing the\n' | 444 'allowed but being removed. Can you avoid introducing the\n' |
452 '#include? See relevant DEPS file(s) for details and contacts.', | 445 '#include? See relevant DEPS file(s) for details and contacts.', |
453 warning_descriptions)) | 446 warning_descriptions)) |
454 return results | 447 return results |
455 | 448 |
456 | 449 |
457 def _CheckFilePermissions(input_api, output_api): | 450 def _CheckFilePermissions(input_api, output_api): |
458 """Check that all files have their permissions properly set.""" | 451 """Check that all files have their permissions properly set.""" |
459 args = [sys.executable, 'tools/checkperms/checkperms.py', '--root', | 452 args = [sys.executable, 'tools/checkperms/checkperms.py', '--root', |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
616 """ | 609 """ |
617 | 610 |
618 warnings = [] | 611 warnings = [] |
619 for f in input_api.AffectedFiles(): | 612 for f in input_api.AffectedFiles(): |
620 if f.LocalPath().endswith(('.cc', '.h')): | 613 if f.LocalPath().endswith(('.cc', '.h')): |
621 changed_linenums = set(line_num for line_num, _ in f.ChangedContents()) | 614 changed_linenums = set(line_num for line_num, _ in f.ChangedContents()) |
622 warnings.extend(_CheckIncludeOrderInFile(input_api, f, changed_linenums)) | 615 warnings.extend(_CheckIncludeOrderInFile(input_api, f, changed_linenums)) |
623 | 616 |
624 results = [] | 617 results = [] |
625 if warnings: | 618 if warnings: |
626 if not input_api.is_committing: | 619 # We don't warn on commit, to avoid stopping commits going through CQ. |
627 results.append(output_api.PresubmitPromptWarning(_INCLUDE_ORDER_WARNING, | 620 results.append(output_api.PresubmitPromptOrNotify(_INCLUDE_ORDER_WARNING, |
628 warnings)) | |
629 else: | |
630 # We don't warn on commit, to avoid stopping commits going through CQ. | |
631 results.append(output_api.PresubmitNotifyResult(_INCLUDE_ORDER_WARNING, | |
632 warnings)) | 621 warnings)) |
633 return results | 622 return results |
634 | 623 |
635 | 624 |
636 def _CheckForVersionControlConflictsInFile(input_api, f): | 625 def _CheckForVersionControlConflictsInFile(input_api, f): |
637 pattern = input_api.re.compile('^(?:<<<<<<<|>>>>>>>) |^=======$') | 626 pattern = input_api.re.compile('^(?:<<<<<<<|>>>>>>>) |^=======$') |
638 errors = [] | 627 errors = [] |
639 for line_num, line in f.ChangedContents(): | 628 for line_num, line in f.ChangedContents(): |
640 if pattern.match(line): | 629 if pattern.match(line): |
641 errors.append(' %s:%d %s' % (f.LocalPath(), line_num, line)) | 630 errors.append(' %s:%d %s' % (f.LocalPath(), line_num, line)) |
(...skipping 28 matching lines...) Expand all Loading... | |
670 input_api.DEFAULT_BLACK_LIST)) | 659 input_api.DEFAULT_BLACK_LIST)) |
671 | 660 |
672 pattern = input_api.re.compile('"[^"]*google\.com[^"]*"') | 661 pattern = input_api.re.compile('"[^"]*google\.com[^"]*"') |
673 problems = [] # items are (filename, line_number, line) | 662 problems = [] # items are (filename, line_number, line) |
674 for f in input_api.AffectedSourceFiles(FilterFile): | 663 for f in input_api.AffectedSourceFiles(FilterFile): |
675 for line_num, line in f.ChangedContents(): | 664 for line_num, line in f.ChangedContents(): |
676 if pattern.search(line): | 665 if pattern.search(line): |
677 problems.append((f.LocalPath(), line_num, line)) | 666 problems.append((f.LocalPath(), line_num, line)) |
678 | 667 |
679 if problems: | 668 if problems: |
680 if not input_api.is_committing: | 669 # We don't want to block use of the CQ when there is a warning |
681 warning_factory = output_api.PresubmitPromptWarning | 670 # of this kind, so we only show a message when committing. |
682 else: | 671 return [output_api.PresubmitPromptOrNotify( |
683 # We don't want to block use of the CQ when there is a warning | |
684 # of this kind, so we only show a message when committing. | |
685 warning_factory = output_api.PresubmitNotifyResult | |
686 return [warning_factory( | |
687 'Most layers below src/chrome/ should not hardcode service URLs.\n' | 672 'Most layers below src/chrome/ should not hardcode service URLs.\n' |
688 'Are you sure this is correct? (Contact: joi@chromium.org)', | 673 'Are you sure this is correct? (Contact: joi@chromium.org)', |
689 [' %s:%d: %s' % ( | 674 [' %s:%d: %s' % ( |
690 problem[0], problem[1], problem[2]) for problem in problems])] | 675 problem[0], problem[1], problem[2]) for problem in problems])] |
691 else: | 676 else: |
692 return [] | 677 return [] |
693 | 678 |
694 | 679 |
695 def _CheckNoAbbreviationInPngFileName(input_api, output_api): | 680 def _CheckNoAbbreviationInPngFileName(input_api, output_api): |
696 """Makes sure there are no abbreviations in the name of PNG files. | 681 """Makes sure there are no abbreviations in the name of PNG files. |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
940 'win_rel', | 925 'win_rel', |
941 'win:compile', | 926 'win:compile', |
942 ] | 927 ] |
943 | 928 |
944 # Match things like path/aura/file.cc and path/file_aura.cc. | 929 # Match things like path/aura/file.cc and path/file_aura.cc. |
945 # Same for chromeos. | 930 # Same for chromeos. |
946 if any(re.search('[/_](aura|chromeos)', f) for f in files): | 931 if any(re.search('[/_](aura|chromeos)', f) for f in files): |
947 trybots += ['linux_chromeos_clang:compile', 'linux_chromeos_asan'] | 932 trybots += ['linux_chromeos_clang:compile', 'linux_chromeos_asan'] |
948 | 933 |
949 return trybots | 934 return trybots |
OLD | NEW |