mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-13 04:30:28 +00:00
-- Note that max line length is 200 (maximum allowed by tool) -- Pre-commit hook tested and uses the same option file as CI Signed-off-by: Raphael Defosseux <raphael.defosseux@eurecom.fr>
32 lines
695 B
Plaintext
32 lines
695 B
Plaintext
|
|
#!/bin/bash
|
|
# Installation:
|
|
# cp pre-commit .git/hooks
|
|
# chmod +x .git/hooks/pre-commit
|
|
|
|
OPTIONS="--options=ci-scripts/astyle-options.txt"
|
|
|
|
RETURN=0
|
|
ASTYLE=$(which astyle)
|
|
if [ $? -ne 0 ]; then
|
|
echo "[!] astyle not installed. Unable to check source file format policy." >&2
|
|
exit 1
|
|
fi
|
|
|
|
FILES=`git diff --cached --name-only --diff-filter=ACMR | grep -E "\.(c|cpp|h)$"`
|
|
for FILE in $FILES; do
|
|
$ASTYLE $OPTIONS < $FILE | cmp -s $FILE -
|
|
if [ $? -ne 0 ]; then
|
|
echo "[!] $FILE does not respect the agreed coding style." >&2
|
|
RETURN=1
|
|
fi
|
|
done
|
|
|
|
if [ $RETURN -eq 1 ]; then
|
|
echo "" >&2
|
|
echo "Make sure you have run astyle with the following options:" >&2
|
|
echo $OPTIONS >&2
|
|
fi
|
|
|
|
exit $RETURN
|