From 2716ce7a56589ca504d9e354c74ccd7efb4bef9b Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Thu, 21 Oct 2021 14:04:53 +0200 Subject: [PATCH] pre-commit hook: clear output with error, file name, diff, instructions --- Tools/astyle/check_code_style.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tools/astyle/check_code_style.sh b/Tools/astyle/check_code_style.sh index ed5bf7ff3c..3a2fcef35b 100755 --- a/Tools/astyle/check_code_style.sh +++ b/Tools/astyle/check_code_style.sh @@ -8,16 +8,16 @@ if [ -f "$FILE" ]; then if [ -n "$CHECK_FAILED" ]; then ${DIR}/fix_code_style.sh --quiet < $FILE > $FILE.pretty + echo -e 'Formatting issue found in' $FILE 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 echo if [[ $PX4_ASTYLE_FIX -eq 1 ]]; then ${DIR}/fix_code_style.sh $FILE else - # Provide instructions - echo $FILE 'bad formatting, please run "make format" or "./Tools/astyle/fix_code_style.sh' $FILE'"' + echo 'to fix automatically run "make format" or "./Tools/astyle/fix_code_style.sh' $FILE'"' exit 1 fi fi