archived-mpp/hooks/pre-commit.hook
Lin Kesheng d5dceef2c4 [coding-style]: add git hook to format code
1. please run hooks/install_hooks.sh manually for the first time
2. hooks/pre-commit.hook is called before commit automatically
3. format code

Change-Id: I4565b206da10abb59506ef73f62392c9e9690cd4
Signed-off-by: Lin Kesheng <lks@rock-chips.com>
2017-02-24 17:30:53 +08:00

31 lines
554 B
Bash
Executable file

#!/bin/sh
out_file="./fmt_df.txt"
cur_dir=$(pwd)
script_dir=tools/
echo "[git-hook]: before commit, format code use mpp_astyle.sh ..."
cd $script_dir
./mpp_astyle.sh
cd $cur_dir
git diff > $out_file
if [ -s $out_file ]
then {
echo "[git-hook]: code changed after formating, please commit again."
rm $out_file
echo "[git-hook]: git status below:"
git status
exit 1
} else {
echo "[git-hook]: nothing change after formating, commit continues."
if [ -f $out_file ]
then {
rm $out_file
} fi
exit 0
} fi