coreboot-kgpe-d16/util/lint/lint-stable-022-clang-format
Angel Pons ce828b6ae8 util/lint: make clang-format non-fatal
The current clang-format configuration is completely broken. It forces
one to change the code style of patches before pushing them, only to
find out that checkpatch now complains about it. This means newcomers
get scared away, and developers only get angered and frustrated about
it, and end up working around clang-format's requirements anyway.

For now, make clang-format's complaints non-fatal, reducing them to text
noise. However, since clang-format is currently unusable, reverting it
out would be preferred.

Change-Id: Iffa8934efa1c27c04e10545f66d8f9976e74c367
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/35176
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2019-09-19 10:20:50 +00:00

38 lines
1.2 KiB
Bash
Executable file

#!/bin/sh
# This file is part of the coreboot project.
#
# Copyright (C) 2018 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# DESCR: Run clang-format on white-listed directories
LC_ALL=C export LC_ALL
# until we require this by default, we need a list of opted-in directories
if [ ! -f .clang-format-scope ]; then
exit 0
fi
files_to_check=$(git log HEAD~..HEAD --format= --name-only $(cat .clang-format-scope) |grep "\.[ch]$")
# nothing to do
if [ -z "$files_to_check" ]; then
exit 0
fi
if [ $(clang-format $files_to_check | wc -l) -gt 0 ]; then
if [ "$(git diff --no-prefix HEAD~..HEAD -- $files_to_check | clang-format-diff)" != "" ]; then
echo "Coding style mismatch. The following patch fixes it:"
git diff --no-prefix HEAD~..HEAD -- $files_to_check | clang-format-diff
exit 0
fi
fi