1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00
RIOT/dist/tools/uncrustify/uncrustify.sh
Kaspar Schleiser fda6ef6ac6 dist/tools/uncrustify/uncrustify.sh: fix uncrustify check logic
Previously, uncrustify.sh would fail (report uncrustifying necessary) if
there was any output of uncrustify. Turns out uncrustify sometimes
outputs something.

This commit changes the logic to use uncrustify's output value as
indicator.

Also, adds printing which file causes the check to fail.
2020-04-29 09:51:36 +02:00

44 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
RIOTBASE=$(git rev-parse --show-toplevel)
CURDIR=$(cd "$(dirname "$0")" && pwd)
UNCRUSTIFY_CFG="$RIOTBASE"/uncrustify-riot.cfg
WHITELIST=$CURDIR/whitelist.txt
BLACKLIST=$CURDIR/blacklist.txt
. "$RIOTBASE"/dist/tools/ci/changed_files.sh
# only consider whitelisted stuff, then filter out blacklist
# note: this also applies changed_files' default filter
FILES=$(changed_files | grep -xf "$WHITELIST" | grep -xvf "$BLACKLIST")
check () {
for F in $FILES
do
uncrustify -c "$UNCRUSTIFY_CFG" -f "$RIOTBASE/$F" \
--check > /dev/null 2>&1 || {
echo "file $F needs to be uncrustified."
echo "Please run 'dist/tools/uncrustify/uncrustify.sh'"
exit 1
}
done
echo "All files are uncrustified!"
}
exec_uncrustify () {
if [ "$(git diff HEAD)" ] ; then
echo "Please commit all changes before running uncrustify.sh"
exit 1
fi
for F in $FILES
do
uncrustify -c "$UNCRUSTIFY_CFG" --no-backup "$RIOTBASE/$F"
done
}
if [ "$1" == "--check" ] ; then
check
else
exec_uncrustify
fi