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

Side by Side Diff: PRESUBMIT.py

Issue 11448014: Add a presubmit check to prevent committing .rej/.orig patch files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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') | PRESUBMIT_test.py » ('J')
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 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 results.extend(_CheckNoNewWStrings(input_api, output_api)) 682 results.extend(_CheckNoNewWStrings(input_api, output_api))
683 results.extend(_CheckNoDEPSGIT(input_api, output_api)) 683 results.extend(_CheckNoDEPSGIT(input_api, output_api))
684 results.extend(_CheckNoBannedFunctions(input_api, output_api)) 684 results.extend(_CheckNoBannedFunctions(input_api, output_api))
685 results.extend(_CheckNoPragmaOnce(input_api, output_api)) 685 results.extend(_CheckNoPragmaOnce(input_api, output_api))
686 results.extend(_CheckNoTrinaryTrueFalse(input_api, output_api)) 686 results.extend(_CheckNoTrinaryTrueFalse(input_api, output_api))
687 results.extend(_CheckUnwantedDependencies(input_api, output_api)) 687 results.extend(_CheckUnwantedDependencies(input_api, output_api))
688 results.extend(_CheckFilePermissions(input_api, output_api)) 688 results.extend(_CheckFilePermissions(input_api, output_api))
689 results.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api, output_api)) 689 results.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api, output_api))
690 results.extend(_CheckIncludeOrder(input_api, output_api)) 690 results.extend(_CheckIncludeOrder(input_api, output_api))
691 results.extend(_CheckForVersionControlConflicts(input_api, output_api)) 691 results.extend(_CheckForVersionControlConflicts(input_api, output_api))
692 results.extend(_CheckPatchFiles(input_api, output_api))
692 693
693 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): 694 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()):
694 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( 695 results.extend(input_api.canned_checks.RunUnitTestsInDirectory(
695 input_api, output_api, 696 input_api, output_api,
696 input_api.PresubmitLocalPath(), 697 input_api.PresubmitLocalPath(),
697 whitelist=[r'.+_test\.py$'])) 698 whitelist=[r'.+_test\.py$']))
698 return results 699 return results
699 700
700 701
701 def _CheckSubversionConfig(input_api, output_api): 702 def _CheckSubversionConfig(input_api, output_api):
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 return [output_api.PresubmitPromptWarning( 766 return [output_api.PresubmitPromptWarning(
766 ('%s is not in AUTHORS file. If you are a new contributor, please visit' 767 ('%s is not in AUTHORS file. If you are a new contributor, please visit'
767 '\n' 768 '\n'
768 'http://www.chromium.org/developers/contributing-code and read the ' 769 'http://www.chromium.org/developers/contributing-code and read the '
769 '"Legal" section\n' 770 '"Legal" section\n'
770 'If you are a chromite, verify the contributor signed the CLA.') % 771 'If you are a chromite, verify the contributor signed the CLA.') %
771 author)] 772 author)]
772 return [] 773 return []
773 774
774 775
776 def _CheckPatchFiles(input_api, output_api):
777 if_patch_file = input_api.re.compile(r'.*\.(rej|orig)$')
778 problems = [f.LocalPath() for f in input_api.AffectedFiles() if
779 if_patch_file.match(f.LocalPath())]
M-A Ruel 2012/12/05 19:30:17 if f.LocalPath().endswith(('.orig', '.rej')) is cl
780 if problems:
781 return [output_api.PresubmitError(
782 "Don't commit .rej and .orig files.", problems)]
783 else:
784 return []
785
786
775 def CheckChangeOnUpload(input_api, output_api): 787 def CheckChangeOnUpload(input_api, output_api):
776 results = [] 788 results = []
777 results.extend(_CommonChecks(input_api, output_api)) 789 results.extend(_CommonChecks(input_api, output_api))
778 return results 790 return results
779 791
780 792
781 def CheckChangeOnCommit(input_api, output_api): 793 def CheckChangeOnCommit(input_api, output_api):
782 results = [] 794 results = []
783 results.extend(_CommonChecks(input_api, output_api)) 795 results.extend(_CommonChecks(input_api, output_api))
784 # TODO(thestig) temporarily disabled, doesn't work in third_party/ 796 # TODO(thestig) temporarily disabled, doesn't work in third_party/
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 'win_aura', 846 'win_aura',
835 'win_rel', 847 'win_rel',
836 ] 848 ]
837 849
838 # Match things like path/aura/file.cc and path/file_aura.cc. 850 # Match things like path/aura/file.cc and path/file_aura.cc.
839 # Same for chromeos. 851 # Same for chromeos.
840 if any(re.search('[/_](aura|chromeos)', f) for f in files): 852 if any(re.search('[/_](aura|chromeos)', f) for f in files):
841 trybots += ['linux_chromeos_clang:compile', 'linux_chromeos_asan'] 853 trybots += ['linux_chromeos_clang:compile', 'linux_chromeos_asan']
842 854
843 return trybots 855 return trybots
OLDNEW
« no previous file with comments | « no previous file | PRESUBMIT_test.py » ('j') | PRESUBMIT_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698