From be0fca914efd7aec719cf5645ce5d6fde0fe2a86 Mon Sep 17 00:00:00 2001 From: Petri Lehtinen Date: Thu, 17 Oct 2019 09:30:31 +0300 Subject: Add scripts for running clang-format --- scripts/clang-format | 3 +++ scripts/clang-format-ci | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100755 scripts/clang-format create mode 100755 scripts/clang-format-ci (limited to 'scripts') diff --git a/scripts/clang-format b/scripts/clang-format new file mode 100755 index 0000000..d46056c --- /dev/null +++ b/scripts/clang-format @@ -0,0 +1,3 @@ +#!/bin/bash + +find . -type f -a '(' -name '*.c' -o -name '*.h' ')' | xargs clang-format -i diff --git a/scripts/clang-format-ci b/scripts/clang-format-ci new file mode 100755 index 0000000..2051262 --- /dev/null +++ b/scripts/clang-format-ci @@ -0,0 +1,18 @@ +#!/bin/bash + +errors=0 +paths=$(find . -type f -a '(' -name '*.c' -o -name '*.h' ')') +for path in $paths; do + in=$(cat $path) + out=$(clang-format $path) + + if [ "$in" != "$out" ]; then + diff -u -L $path -L "$path.formatted" $path - <<<$out + errors=1 + fi +done + +if [ $errors -ne 0 ]; then + echo "Formatting errors detected, run ./scripts/clang-format to fix!" + exit 1 +fi -- cgit v1.1