mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 14:33:52 +01:00
uncrustify: add CI check
Co-authored-by: Kaspar Schleiser <kaspar@schleiser.de>
This commit is contained in:
parent
3b423a959d
commit
9f1b2f2550
0
dist/tools/uncrustify/blacklist.txt
vendored
Normal file
0
dist/tools/uncrustify/blacklist.txt
vendored
Normal file
42
dist/tools/uncrustify/uncrustify.sh
vendored
Executable file
42
dist/tools/uncrustify/uncrustify.sh
vendored
Executable file
@ -0,0 +1,42 @@
|
||||
#!/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
|
||||
OUT="$(uncrustify -c "$UNCRUSTIFY_CFG" -f "$RIOTBASE/$F" --check 2> /dev/null)"
|
||||
if [ "$OUT" ] ; then
|
||||
echo "Please run 'dist/tools/uncrustify/uncrustify.sh'"
|
||||
exit 1
|
||||
fi
|
||||
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
|
||||
0
dist/tools/uncrustify/whitelist.txt
vendored
Normal file
0
dist/tools/uncrustify/whitelist.txt
vendored
Normal file
Loading…
x
Reference in New Issue
Block a user