diff options
author | bradnelson@google.com <bradnelson@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-27 16:47:39 +0000 |
---|---|---|
committer | bradnelson@google.com <bradnelson@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-27 16:47:39 +0000 |
commit | 22c9bd7714bbb6bce762f29dd2be259cd37c92ed (patch) | |
tree | efaf89ed4d6d37a68218dc81cdaa7af713065e61 /PRESUBMIT.py | |
parent | b57bd61fea33b77586bdae6b3599af0fc256d38e (diff) | |
download | chromium_src-22c9bd7714bbb6bce762f29dd2be259cd37c92ed.zip chromium_src-22c9bd7714bbb6bce762f29dd2be259cd37c92ed.tar.gz chromium_src-22c9bd7714bbb6bce762f29dd2be259cd37c92ed.tar.bz2 |
Migrating common checks to a location that affects all chromium projects.
BUG=None
TEST=None
R=erikkay@chromium.org,dpranke@chromium.org,maruel@chromium.org
Review URL: http://codereview.chromium.org/6676115
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79515 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'PRESUBMIT.py')
-rw-r--r-- | PRESUBMIT.py | 102 |
1 files changed, 9 insertions, 93 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 8b7999d..6b08653 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -8,8 +8,6 @@ See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for more details about the presubmit API built into gcl. """ -import time - _EXCLUDED_PATHS = ( r"^breakpad[\\\/].*", r"^net/tools/spdyshark/[\\\/].*", @@ -18,24 +16,12 @@ _EXCLUDED_PATHS = ( r".*MakeFile$", ) -_TEXT_FILES = ( - r".*\.txt", - r".*\.json", -) - -_LICENSE_HEADER = ( - r".*? Copyright \(c\) %s The Chromium Authors\. All rights reserved\.\n" - r".*? Use of this source code is governed by a BSD-style license that can " - "be\n" - r".*? found in the LICENSE file\." - "\n" -) % time.strftime("%Y") -def _CheckNoInterfacesInBase(input_api, output_api, source_file_filter): +def _CheckNoInterfacesInBase(input_api, output_api): """Checks to make sure no files in libbase.a have |@interface|.""" pattern = input_api.re.compile(r'@interface') files = [] - for f in input_api.AffectedSourceFiles(source_file_filter): + for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): if (f.LocalPath().find('base/') != -1 and f.LocalPath().find('base/test/') == -1): contents = input_api.ReadFile(f) @@ -50,24 +36,14 @@ def _CheckNoInterfacesInBase(input_api, output_api, source_file_filter): files) ] return [] -def _CheckSingletonInHeaders(input_api, output_api, source_file_filter): - """Checks to make sure no header files have |Singleton<|.""" - pattern = input_api.re.compile(r'Singleton<') - files = [] - for f in input_api.AffectedSourceFiles(source_file_filter): - if (f.LocalPath().endswith('.h') or f.LocalPath().endswith('.hxx') or - f.LocalPath().endswith('.hpp') or f.LocalPath().endswith('.inl')): - contents = input_api.ReadFile(f) - if pattern.search(contents): - files.append(f) - if len(files): - return [ output_api.PresubmitError( - 'Found Singleton<T> in the following header files.\n' + - 'Please move them to an appropriate source file so that the ' + - 'template gets instantiated in a single compilation unit.', - files) ] - return [] +def _CommonChecks(input_api, output_api): + """Checks common to both upload and commit.""" + results = [] + results.extend(input_api.canned_checks.PanProjectChecks( + input_api, output_api, excluded_paths=_EXCLUDED_PATHS)) + results.extend(_CheckNoInterfacesInBase(input_api, output_api)) + return results def _CheckSubversionConfig(input_api, output_api): @@ -114,66 +90,6 @@ def _CheckSubversionConfig(input_api, output_api): return [] -def _CheckConstNSObject(input_api, output_api, source_file_filter): - """Checks to make sure no objective-c files have |const NSSomeClass*|.""" - pattern = input_api.re.compile(r'const\s+NS\w*\s*\*') - files = [] - for f in input_api.AffectedSourceFiles(source_file_filter): - if f.LocalPath().endswith('.h') or f.LocalPath().endswith('.mm'): - contents = input_api.ReadFile(f) - if pattern.search(contents): - files.append(f) - - if len(files): - if input_api.is_committing: - res_type = output_api.PresubmitPromptWarning - else: - res_type = output_api.PresubmitNotifyResult - return [ res_type('|const NSClass*| is wrong, see ' + - 'http://dev.chromium.org/developers/clang-mac', - files) ] - return [] - - -def _CommonChecks(input_api, output_api): - results = [] - # What does this code do? - # It loads the default black list (e.g. third_party, experimental, etc) and - # add our black list (breakpad, skia and v8 are still not following - # google style and are not really living this repository). - # See presubmit_support.py InputApi.FilterSourceFile for the (simple) usage. - black_list = input_api.DEFAULT_BLACK_LIST + _EXCLUDED_PATHS - white_list = input_api.DEFAULT_WHITE_LIST + _TEXT_FILES - sources = lambda x: input_api.FilterSourceFile(x, black_list=black_list) - text_files = lambda x: input_api.FilterSourceFile(x, black_list=black_list, - white_list=white_list) - - # TODO(dpranke): enable upload as well - if input_api.is_committing: - results.extend(input_api.canned_checks.CheckOwners( - input_api, output_api, source_file_filter=sources)) - - results.extend(input_api.canned_checks.CheckLongLines( - input_api, output_api, source_file_filter=sources)) - results.extend(input_api.canned_checks.CheckChangeHasNoTabs( - input_api, output_api, source_file_filter=sources)) - results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( - input_api, output_api, source_file_filter=sources)) - results.extend(input_api.canned_checks.CheckChangeSvnEolStyle( - input_api, output_api, source_file_filter=text_files)) - results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( - input_api, output_api)) - results.extend(input_api.canned_checks.CheckLicense( - input_api, output_api, _LICENSE_HEADER, source_file_filter=sources)) - results.extend(_CheckConstNSObject( - input_api, output_api, source_file_filter=sources)) - results.extend(_CheckSingletonInHeaders( - input_api, output_api, source_file_filter=sources)) - results.extend(_CheckNoInterfacesInBase( - input_api, output_api, source_file_filter=sources)) - return results - - def CheckChangeOnUpload(input_api, output_api): results = [] results.extend(_CommonChecks(input_api, output_api)) |