X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=scr%2Fgit%2Fpre-commit.sh;h=01e85e9d740e2db80b3d2743b70dcb9f6424bd6b;hb=61c8b6e85a24b5b6b9e9bc40dbeda77726e57283;hp=e9ded58de95675360551084552b5915b374ac93f;hpb=6fad401807254ca484b90304ded9501ce4d1cf99;p=anna.git diff --git a/scr/git/pre-commit.sh b/scr/git/pre-commit.sh index e9ded58..01e85e9 100755 --- a/scr/git/pre-commit.sh +++ b/scr/git/pre-commit.sh @@ -48,10 +48,9 @@ then fi # Astyle -version=`astyle --version 2> /dev/null` -if test "x$version" != "x"; then -echo "SDF3 git pre-receive hook:" -echo "Did not find astyle, please install it before continuing." +which astyle >/dev/null 2>/dev/null +if [ $? -ne 0 ]; then +echo "pre-commit hook: 'astyle' not found, install it before continuing or remove .fix_style to skip astyle processing." exit 1 fi ASTYLE=astyle @@ -60,8 +59,7 @@ case `$ASTYLE --version 2> /dev/null` in Artistic*) ;; default) - echo "SDF3 git pre-commit hook:" - echo "Did not find astyle, please install it before continuing." + echo "pre-commit hook: unsupported astyle version, must be 'Artistic Style Version x.xx'. Install or skip (remove .fix_style)." exit 1 ;; esac @@ -90,13 +88,18 @@ test_style () { file=$1 newfile=${file}.astyled #$ASTYLE ${ASTYLE_PARAMETERS} < $file > $newfile 2>>/dev/null - $ASTYLE -a -f -p -o -O -c -s2 -U -x --mode=c < $file > $newfile 2>>/dev/null + echo "Executing $ASTYLE -a -f -p -o -O -c -s2 -U --mode=c < $file > $newfile" + $ASTYLE -a -f -p -o -O -c -s2 -U --mode=c < $file > $newfile + if [ $? -ne 0 ] ; then + echo "Error in astyle" + exit 1 + fi diff "${file}" "${newfile}" - r=$? - if [ $r != 0 ] ; then + if [ $? -ne 0 ] ; then echo "Code style error in '$file', please fix before commiting." if [ -f "./.fix_style" ]; then echo "Auto-fixing code style..." + cp $file ${file}.orig mv $newfile $file else echo "To autofix, create a hidden file named './.fix_style' on suite root." @@ -115,7 +118,7 @@ for file in $files; do x=`echo $file |grep -E '(\.cpp|\.hpp)'` if test "x$x" != "x"; then test_style $file - #git add $file + git add $file fi done