Files
rk35xx-android14/external/camera_engine_rkaiq/tools/pre-commit-code-style.sh
T
hmz007 36ed224bac Rockchip Anroid14_SDK 20240628-rkr5 (2556df1a)
Signed-off-by: hmz007 <hmz007@gmail.com>
Change-Id: Ib87fdbe7a0be7dc961af3500fe9ea4589a127f9f
2024-10-29 18:12:02 +08:00

25 lines
772 B
Bash

#!/bin/sh
# checking code style before commit
ASTYLE=astyle
ASTYLE_PARAMS="--indent=spaces=4 --convert-tabs --pad-oper --suffix=none"
DOS2UNIX=dos2unix
DOS2UNIX_PARAMS="-ascii --safe --keepdate --quiet"
command -v $ASTYLE > /dev/null 2>&1 || echo "warning: $ASTYLE is not installed"
command -v $DOS2UNIX > /dev/null 2>&1 || echo "warning: $DOS2UNIX is not installed"
echo "---- checking code style (dos2unix / astyle)----"
for file in `git diff-index --cached --name-only -M HEAD | grep -E "\.c$|\.cpp$|\.h$|\.hpp$" ` ; do
$DOS2UNIX ${DOS2UNIX_PARAMS} ${file}
$ASTYLE ${ASTYLE_PARAMS} ${file}
ret=$?
if [ $ret != 0 ] ; then
echo "code style failed on $file"
exit 1
fi
git add $file
done
echo "---- checking code style done----"