mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-04 00:36:23 +08:00

Set pre-commit hook to detect changes on staged file. Change-Id: I041a82577263abcdfffc146b5aaba1d0a51def76 Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
32 lines
573 B
Bash
Executable File
32 lines
573 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 status -s | grep "^MM " > $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
|
|
|