xref: /rockchip-linux_mpp/tools/hooks/pre-commit (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1#!/bin/sh
2
3out_file="./fmt_df.txt"
4cur_dir=$(pwd)
5script_dir=tools/
6
7echo "[git-hook]: before commit, format code use mpp_astyle.sh ..."
8
9cd $script_dir
10./mpp_astyle.sh
11
12cd $cur_dir
13
14git status -s | grep "^MM " > $out_file
15
16if [ -s $out_file ]
17then {
18    echo "[git-hook]: code changed after formating, please commit again."
19    rm $out_file
20    echo "[git-hook]: git status below:"
21    git status
22    exit 1
23} else {
24    echo "[git-hook]: nothing change after formating, commit continues."
25    if [ -f $out_file ]
26    then {
27        rm $out_file
28    } fi
29    exit 0
30} fi
31
32