VM: Enforce correctly formatted C++ code

Currently the presubmit script for 'git cl upload' will just warn the developer
that code is incorrectly formatted and asks whether to proceed. This makes
developers sometimes just ignore the warning and upload incorrectly formatted
C++ code.

This causes incorrectly formatted code to be committed to the repository and
will cause a presubmit warning/question for all developers afterwards.

This CL will therefore turn the warning into an error to ensure our c++ code is
always correctly formatted.

R=zra@google.com

Review URL: https://codereview.chromium.org/2525633002 .
This commit is contained in:
Martin Kustermann 2016-11-30 23:52:52 +01:00
parent d822f36f15
commit 554c3c9683

View file

@ -5,6 +5,7 @@
import os
import cpplint
import re
import StringIO
# memcpy does not handle overlapping memory regions. Even though this
# is well documented it seems to be used in error quite often. To avoid
@ -49,7 +50,17 @@ def CheckGn(input_api, output_api):
def CheckFormatted(input_api, output_api):
return input_api.canned_checks.CheckPatchFormatted(input_api, output_api)
def convert_warning_to_error(presubmit_result):
if not presubmit_result.fatal:
# Convert this warning to an error.
stream = StringIO.StringIO()
presubmit_result.handle(stream)
message = stream.getvalue()
return output_api.PresubmitError(message)
return presubmit_result
results = input_api.canned_checks.CheckPatchFormatted(input_api, output_api)
return [convert_warning_to_error(r) for r in results]
def CheckChangeOnUpload(input_api, output_api):