2015-01-06 00:16:30 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2016-08-22 18:20:27 -03:00
|
|
|
FILE=$1
|
2016-04-21 18:29:49 -03:00
|
|
|
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
|
|
|
|
2016-08-22 18:20:27 -03:00
|
|
|
if [ -f "$FILE" ]; then
|
2018-05-08 07:48:08 -03:00
|
|
|
CHECK_FAILED=$(${DIR}/fix_code_style.sh --dry-run --formatted $FILE)
|
2018-05-08 13:04:26 -03:00
|
|
|
if [ -n "$CHECK_FAILED" ]; then
|
2016-08-22 18:20:27 -03:00
|
|
|
${DIR}/fix_code_style.sh --quiet < $FILE > $FILE.pretty
|
2016-06-21 12:49:42 -03:00
|
|
|
|
2021-10-21 09:04:53 -03:00
|
|
|
echo -e 'Formatting issue found in' $FILE
|
2016-06-21 12:49:42 -03:00
|
|
|
echo
|
2021-10-21 09:04:53 -03:00
|
|
|
git --no-pager diff --no-index --minimal --histogram --color=always $FILE $FILE.pretty | grep -vE -e "^.{,4}diff.*\.pretty.{,3}$" -e "^.{,4}--- a/.*$" -e "^.{,4}\+\+\+ b/.*$" -e "^.{,5}@@ .* @@.*$" -e "^.{,4}index .{10}\.\."
|
2016-08-22 18:20:27 -03:00
|
|
|
rm -f $FILE.pretty
|
2016-06-21 12:49:42 -03:00
|
|
|
echo
|
|
|
|
|
2016-08-22 18:20:27 -03:00
|
|
|
if [[ $PX4_ASTYLE_FIX -eq 1 ]]; then
|
|
|
|
${DIR}/fix_code_style.sh $FILE
|
2016-08-05 23:23:32 -03:00
|
|
|
else
|
2021-10-21 09:04:53 -03:00
|
|
|
echo 'to fix automatically run "make format" or "./Tools/astyle/fix_code_style.sh' $FILE'"'
|
2016-08-05 23:23:32 -03:00
|
|
|
exit 1
|
|
|
|
fi
|
2016-04-24 20:25:31 -03:00
|
|
|
fi
|
2015-01-06 00:16:30 -04:00
|
|
|
fi
|