px4-firmware/Tools/check_code_style.sh

24 lines
582 B
Bash
Raw Normal View History

#!/usr/bin/env bash
FILE=$1
2016-04-21 18:29:49 -03:00
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
2016-06-21 12:49:42 -03:00
echo
git --no-pager diff --no-index --minimal --histogram --color=always $FILE $FILE.pretty
rm -f $FILE.pretty
2016-06-21 12:49:42 -03:00
echo
if [[ $PX4_ASTYLE_FIX -eq 1 ]]; then
${DIR}/fix_code_style.sh $FILE
else
echo $FILE 'bad formatting, please run "make format" or "./Tools/fix_code_style.sh' $FILE'"'
exit 1
fi
fi
fi