mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-07 17:35:22 +08:00
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:
+10
-16
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user