filtering files for code check seperately to enable fast use of git pre-commit hook to check code style

ask user to install pre-commit hook when code style is checked
This commit is contained in:
Andreas Antener
2016-08-22 23:20:27 +02:00
parent 93201835d3
commit cbbf5e2e7c
8 changed files with 136 additions and 67 deletions
+10 -16
View File
@@ -1,29 +1,23 @@
#!/usr/bin/env bash
file=$1
FILE=$1
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [ -f "$file" ];
then
${DIR}/fix_code_style.sh --dry-run $file | grep --quiet Formatted
if [[ $? -eq 0 ]]
then
${DIR}/fix_code_style.sh --quiet < $file > $file.pretty
if [ -f "$FILE" ]; then
${DIR}/fix_code_style.sh --dry-run $FILE | grep --quiet Formatted
if [[ $? -eq 0 ]]; then
${DIR}/fix_code_style.sh --quiet < $FILE > $FILE.pretty
echo
git --no-pager diff --no-index --minimal --histogram --color=always $file $file.pretty
git --no-pager diff --no-index --minimal --histogram --color=always $FILE $FILE.pretty
rm -f $FILE.pretty
echo
rm -f $file.pretty
if [[ $PX4_ASTYLE_FIX -eq 1 ]]
then
${DIR}/fix_code_style.sh $file
if [[ $PX4_ASTYLE_FIX -eq 1 ]]; then
${DIR}/fix_code_style.sh $FILE
else
echo $file 'bad formatting, please run "./Tools/fix_code_style.sh' $file'"'
echo $FILE 'bad formatting, please run "make format" or "./Tools/fix_code_style.sh' $FILE'"'
exit 1
fi
fi
fi