mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-11-03 01:33:35 +08:00
[coding-style]: implement git hook pre-commit
Change-Id: I0270d9c07655a965c5e4fda0cc03e44d0a5d8946 Signed-off-by: Lin Kesheng <lks@rock-chips.com>
This commit is contained in:
31
tools/hooks/pre-commit
Executable file
31
tools/hooks/pre-commit
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/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
|
||||
|
||||
Reference in New Issue
Block a user