From f28ef9887ee23597d4a0b89d068f7b8e377fc876 Mon Sep 17 00:00:00 2001 From: Ryan Tseng Date: Tue, 4 Dec 2018 19:53:08 +0000 Subject: [PATCH] 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/1361560 Reviewed-by: agrieve Commit-Queue: Ryan Tseng --- presubmit_canned_checks.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 6eee8b6bb..144357cee 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -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 []