mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
pre-commit hook: clear output with error, file name, diff, instructions
This commit is contained in:
committed by
Daniel Agar
parent
4454fe9770
commit
2716ce7a56
@@ -8,16 +8,16 @@ if [ -f "$FILE" ]; then
|
|||||||
if [ -n "$CHECK_FAILED" ]; then
|
if [ -n "$CHECK_FAILED" ]; then
|
||||||
${DIR}/fix_code_style.sh --quiet < $FILE > $FILE.pretty
|
${DIR}/fix_code_style.sh --quiet < $FILE > $FILE.pretty
|
||||||
|
|
||||||
|
echo -e 'Formatting issue found in' $FILE
|
||||||
echo
|
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 | grep -vE -e "^.{,4}diff.*\.pretty.{,3}$" -e "^.{,4}--- a/.*$" -e "^.{,4}\+\+\+ b/.*$" -e "^.{,5}@@ .* @@.*$" -e "^.{,4}index .{10}\.\."
|
||||||
rm -f $FILE.pretty
|
rm -f $FILE.pretty
|
||||||
echo
|
echo
|
||||||
|
|
||||||
if [[ $PX4_ASTYLE_FIX -eq 1 ]]; then
|
if [[ $PX4_ASTYLE_FIX -eq 1 ]]; then
|
||||||
${DIR}/fix_code_style.sh $FILE
|
${DIR}/fix_code_style.sh $FILE
|
||||||
else
|
else
|
||||||
# Provide instructions
|
echo 'to fix automatically run "make format" or "./Tools/astyle/fix_code_style.sh' $FILE'"'
|
||||||
echo $FILE 'bad formatting, please run "make format" or "./Tools/astyle/fix_code_style.sh' $FILE'"'
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user