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

Side by Side Diff: PRESUBMIT.py

Issue 13093006: Update PRESUBMIT scripts to use PresubmitPromptOrNotify helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 7 years, 9 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 | PRESUBMIT_test.py » ('j') | 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 """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
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 return [output_api.PresubmitPromptOrNotify(_TEST_ONLY_WARNING, problems)]
227 return [output_api.PresubmitPromptWarning(_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: 227 else:
232 return [] 228 return []
233 229
234 230
235 def _CheckNoIOStreamInHeaders(input_api, output_api): 231 def _CheckNoIOStreamInHeaders(input_api, output_api):
236 """Checks to make sure no .h files include <iostream>.""" 232 """Checks to make sure no .h files include <iostream>."""
237 files = [] 233 files = []
238 pattern = input_api.re.compile(r'^#include\s*<iostream>', 234 pattern = input_api.re.compile(r'^#include\s*<iostream>',
239 input_api.re.MULTILINE) 235 input_api.re.MULTILINE)
240 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): 236 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 error_descriptions.append(description_with_path) 429 error_descriptions.append(description_with_path)
434 else: 430 else:
435 warning_descriptions.append(description_with_path) 431 warning_descriptions.append(description_with_path)
436 432
437 results = [] 433 results = []
438 if error_descriptions: 434 if error_descriptions:
439 results.append(output_api.PresubmitError( 435 results.append(output_api.PresubmitError(
440 'You added one or more #includes that violate checkdeps rules.', 436 'You added one or more #includes that violate checkdeps rules.',
441 error_descriptions)) 437 error_descriptions))
442 if warning_descriptions: 438 if warning_descriptions:
443 if not input_api.is_committing: 439 results.append(output_api.PresubmitPromptOrNotify(
444 warning_factory = output_api.PresubmitPromptWarning
445 else:
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' 440 'You added one or more #includes of files that are temporarily\n'
451 'allowed but being removed. Can you avoid introducing the\n' 441 'allowed but being removed. Can you avoid introducing the\n'
452 '#include? See relevant DEPS file(s) for details and contacts.', 442 '#include? See relevant DEPS file(s) for details and contacts.',
453 warning_descriptions)) 443 warning_descriptions))
454 return results 444 return results
455 445
456 446
457 def _CheckFilePermissions(input_api, output_api): 447 def _CheckFilePermissions(input_api, output_api):
458 """Check that all files have their permissions properly set.""" 448 """Check that all files have their permissions properly set."""
459 args = [sys.executable, 'tools/checkperms/checkperms.py', '--root', 449 args = [sys.executable, 'tools/checkperms/checkperms.py', '--root',
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 """ 606 """
617 607
618 warnings = [] 608 warnings = []
619 for f in input_api.AffectedFiles(): 609 for f in input_api.AffectedFiles():
620 if f.LocalPath().endswith(('.cc', '.h')): 610 if f.LocalPath().endswith(('.cc', '.h')):
621 changed_linenums = set(line_num for line_num, _ in f.ChangedContents()) 611 changed_linenums = set(line_num for line_num, _ in f.ChangedContents())
622 warnings.extend(_CheckIncludeOrderInFile(input_api, f, changed_linenums)) 612 warnings.extend(_CheckIncludeOrderInFile(input_api, f, changed_linenums))
623 613
624 results = [] 614 results = []
625 if warnings: 615 if warnings:
626 if not input_api.is_committing: 616 results.append(output_api.PresubmitPromptOrNotify(_INCLUDE_ORDER_WARNING,
627 results.append(output_api.PresubmitPromptWarning(_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)) 617 warnings))
633 return results 618 return results
634 619
635 620
636 def _CheckForVersionControlConflictsInFile(input_api, f): 621 def _CheckForVersionControlConflictsInFile(input_api, f):
637 pattern = input_api.re.compile('^(?:<<<<<<<|>>>>>>>) |^=======$') 622 pattern = input_api.re.compile('^(?:<<<<<<<|>>>>>>>) |^=======$')
638 errors = [] 623 errors = []
639 for line_num, line in f.ChangedContents(): 624 for line_num, line in f.ChangedContents():
640 if pattern.match(line): 625 if pattern.match(line):
641 errors.append(' %s:%d %s' % (f.LocalPath(), line_num, line)) 626 errors.append(' %s:%d %s' % (f.LocalPath(), line_num, line))
(...skipping 28 matching lines...) Expand all
670 input_api.DEFAULT_BLACK_LIST)) 655 input_api.DEFAULT_BLACK_LIST))
671 656
672 pattern = input_api.re.compile('"[^"]*google\.com[^"]*"') 657 pattern = input_api.re.compile('"[^"]*google\.com[^"]*"')
673 problems = [] # items are (filename, line_number, line) 658 problems = [] # items are (filename, line_number, line)
674 for f in input_api.AffectedSourceFiles(FilterFile): 659 for f in input_api.AffectedSourceFiles(FilterFile):
675 for line_num, line in f.ChangedContents(): 660 for line_num, line in f.ChangedContents():
676 if pattern.search(line): 661 if pattern.search(line):
677 problems.append((f.LocalPath(), line_num, line)) 662 problems.append((f.LocalPath(), line_num, line))
678 663
679 if problems: 664 if problems:
680 if not input_api.is_committing: 665 return [output_api.PresubmitPromptOrNotify(
681 warning_factory = output_api.PresubmitPromptWarning
682 else:
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' 666 'Most layers below src/chrome/ should not hardcode service URLs.\n'
688 'Are you sure this is correct? (Contact: joi@chromium.org)', 667 'Are you sure this is correct? (Contact: joi@chromium.org)',
689 [' %s:%d: %s' % ( 668 [' %s:%d: %s' % (
690 problem[0], problem[1], problem[2]) for problem in problems])] 669 problem[0], problem[1], problem[2]) for problem in problems])]
691 else: 670 else:
692 return [] 671 return []
693 672
694 673
695 def _CheckNoAbbreviationInPngFileName(input_api, output_api): 674 def _CheckNoAbbreviationInPngFileName(input_api, output_api):
696 """Makes sure there are no abbreviations in the name of PNG files. 675 """Makes sure there are no abbreviations in the name of PNG files.
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 'win_rel', 919 'win_rel',
941 'win:compile', 920 'win:compile',
942 ] 921 ]
943 922
944 # Match things like path/aura/file.cc and path/file_aura.cc. 923 # Match things like path/aura/file.cc and path/file_aura.cc.
945 # Same for chromeos. 924 # Same for chromeos.
946 if any(re.search('[/_](aura|chromeos)', f) for f in files): 925 if any(re.search('[/_](aura|chromeos)', f) for f in files):
947 trybots += ['linux_chromeos_clang:compile', 'linux_chromeos_asan'] 926 trybots += ['linux_chromeos_clang:compile', 'linux_chromeos_asan']
948 927
949 return trybots 928 return trybots
OLDNEW
« no previous file with comments | « no previous file | PRESUBMIT_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698