Commit f28ef988 authored by Ryan Tseng's avatar Ryan Tseng Committed by Commit Bot

Add bypass_warnings flag to Commit Format check

Right now, if clang-format is broken, a CL will still pass CQ.
This adds a flag so that it will fail CQ.

Bug: 911708
Change-Id: I2c71b7bc434fc611d51f688266be6a265b80f4da
Reviewed-on: https://chromium-review.googlesource.com/c/1361560Reviewed-by: 's avataragrieve <agrieve@chromium.org>
Commit-Queue: Ryan Tseng <hinoka@chromium.org>
parent ba83229a
......@@ -1062,6 +1062,7 @@ def PanProjectChecks(input_api, output_api,
def CheckPatchFormatted(input_api,
output_api,
bypass_warnings=True,
check_js=False,
check_python=None,
result_factory=None):
......@@ -1092,8 +1093,11 @@ def CheckPatchFormatted(input_api,
# contains the PRESUBMIT.py.
if presubmit_subdir:
cmd.append(input_api.PresubmitLocalPath())
code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True)
if code == 2:
code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=bypass_warnings)
# bypass_warnings? Only fail with code 2.
# As this is just a warning, ignore all other errors if the user
# happens to have a broken clang-format, doesn't use git, etc etc.
if code == 2 or (code and not bypass_warnings):
if presubmit_subdir:
short_path = presubmit_subdir
else:
......@@ -1103,8 +1107,6 @@ def CheckPatchFormatted(input_api,
'The %s directory requires source formatting. '
'Please run: git cl format %s' %
(short_path, ' '.join(display_args)))]
# As this is just a warning, ignore all other errors if the user
# happens to have a broken clang-format, doesn't use git, etc etc.
return []
......
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