Commit 4dff9956 by James Darpinian Committed by Commit Bot

Presubmit check forbidding tab characters in source files.

WebKit's Subversion repository forbids tab characters in source files. Follow-up to: https://chromium-review.googlesource.com/c/angle/angle/+/1954410 Bug: angleproject:3439 Change-Id: I7ab170cae6985c62ee2f163c15d2746f620fe648 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1959750 Commit-Queue: James Darpinian <jdarpinian@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com>
parent 49135f68
...@@ -13,8 +13,8 @@ import subprocess ...@@ -13,8 +13,8 @@ import subprocess
import sys import sys
import tempfile import tempfile
# Fragment of a regular expression that matches C++ and Objective-C++ implementation files. # Fragment of a regular expression that matches C++ and Objective-C++ implementation files and headers.
_IMPLEMENTATION_EXTENSIONS = r'\.(cc|cpp|cxx|mm)$' _IMPLEMENTATION_AND_HEADER_EXTENSIONS = r'\.(cc|cpp|cxx|mm|h|hpp|hxx)$'
# Fragment of a regular expression that matches C++ and Objective-C++ header files. # Fragment of a regular expression that matches C++ and Objective-C++ header files.
_HEADER_EXTENSIONS = r'\.(h|hpp|hxx)$' _HEADER_EXTENSIONS = r'\.(h|hpp|hxx)$'
...@@ -147,8 +147,36 @@ def _CheckExportValidity(input_api, output_api): ...@@ -147,8 +147,36 @@ def _CheckExportValidity(input_api, output_api):
shutil.rmtree(outdir) shutil.rmtree(outdir)
def _CheckTabsInSourceFiles(input_api, output_api):
"""Forbids tab characters in source files due to a WebKit repo requirement. """
def implementation_and_headers(f):
return input_api.FilterSourceFile(
f, white_list=(r'.+%s' % _IMPLEMENTATION_AND_HEADER_EXTENSIONS,))
files_with_tabs = []
for f in input_api.AffectedSourceFiles(implementation_and_headers):
for (num, line) in f.ChangedContents():
if '\t' in line:
files_with_tabs.append(f)
break
if files_with_tabs:
return [
output_api.PresubmitError(
'Tab characters in source files.',
items=sorted(files_with_tabs),
long_text=
'Tab characters are forbidden in ANGLE source files because WebKit\'s Subversion\n'
'repository does not allow tab characters in source files.\n'
'Please remove tab characters from these files.')
]
return []
def CheckChangeOnUpload(input_api, output_api): def CheckChangeOnUpload(input_api, output_api):
results = [] results = []
results.extend(_CheckTabsInSourceFiles(input_api, output_api))
results.extend(_CheckCodeGeneration(input_api, output_api)) results.extend(_CheckCodeGeneration(input_api, output_api))
results.extend(_CheckChangeHasBugField(input_api, output_api)) results.extend(_CheckChangeHasBugField(input_api, output_api))
results.extend(input_api.canned_checks.CheckChangeHasDescription(input_api, output_api)) results.extend(input_api.canned_checks.CheckChangeHasDescription(input_api, output_api))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment