summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@chromium.org>2018-05-24 17:36:41 +0200
committerMartin Roth <martinroth@google.com>2018-05-31 15:33:59 +0000
commitf743728e9fe05705bbac01978368cdd8ddcf2af6 (patch)
tree4c4473d4e21f1578d2b6652a207d273ee5126eb7
parentae2cb2d3bf97983d886545b63b547034d360f593 (diff)
downloadcoreboot-f743728e9fe05705bbac01978368cdd8ddcf2af6.tar.xz
util/lint: Add check that changes conform to clang-format style
It's a white list (configured through $(top)/.clang-format-scope) with the expectation that the list will grow over time. Once everything is covered, we can turn off the white-listing and keep everything enforced. To not drive people crazy, only check the files their commit touched. Change-Id: I52c7ea73fd36aaa46c0bfce928158e1cd6304540 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: https://review.coreboot.org/26514 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
-rwxr-xr-xutil/lint/lint-022-clang-format34
1 files changed, 34 insertions, 0 deletions
diff --git a/util/lint/lint-022-clang-format b/util/lint/lint-022-clang-format
new file mode 100755
index 0000000000..932d9c0d50
--- /dev/null
+++ b/util/lint/lint-022-clang-format
@@ -0,0 +1,34 @@
+#!/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
+ git diff HEAD~..HEAD -- $files_to_check | clang-format-diff
+fi