add cmd check
This commit is contained in:
parent
8de0bef8a5
commit
4f8d45375b
|
@ -14,15 +14,19 @@ changed_files=$(git diff-index --cached $against | \
|
||||||
grep -E '[MA] .*\.(c|cpp|cc|cxx)$' | cut -d' ' -f 2)
|
grep -E '[MA] .*\.(c|cpp|cc|cxx)$' | cut -d' ' -f 2)
|
||||||
|
|
||||||
|
|
||||||
if [ -n "$changed_files" ]; then
|
if which cppcheck > /dev/null; then
|
||||||
cppcheck --enable=warning,performance,portability --inline-suppr --error-exitcode=1 --platform=win64 --force $changed_files
|
if [ -n "$changed_files" ]; then
|
||||||
err=$?
|
cppcheck --enable=warning,performance,portability --inline-suppr --error-exitcode=1 --platform=win64 --force $changed_files
|
||||||
if [ $err -ne 0 ]; then
|
err=$?
|
||||||
echo "[rt-thread][cppcheck] we found a obvious fault, please fix the error then commit again"
|
if [ $err -ne 0 ]; then
|
||||||
exit $err
|
echo "[rt-thread][cppcheck] we found a obvious fault, please fix the error then commit again"
|
||||||
else
|
exit $err
|
||||||
echo "[rt-thread][cppcheck] cppcheck ok."
|
else
|
||||||
|
echo "[rt-thread][cppcheck] cppcheck ok."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "cppcheck does not exist"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# We only filter the file name with c or cpp or h file.
|
# We only filter the file name with c or cpp or h file.
|
||||||
|
@ -30,30 +34,37 @@ fi
|
||||||
changed_files=$(git diff-index --cached $against | \
|
changed_files=$(git diff-index --cached $against | \
|
||||||
grep -E '[MA] .*\.(c|cpp|h)$' | cut -d' ' -f 2)
|
grep -E '[MA] .*\.(c|cpp|h)$' | cut -d' ' -f 2)
|
||||||
|
|
||||||
|
if which astyle > /dev/null; then
|
||||||
if [ -n "$changed_files" ]; then
|
if [ -n "$changed_files" ]; then
|
||||||
astyle --style=allman --indent=spaces=4 --indent=spaces=4 --indent=spaces=4 --pad-header --pad-header --pad-header --align-pointer=name --lineend=linux --convert-tabs --verbose $changed_files
|
astyle --style=allman --indent=spaces=4 --indent=spaces=4 --indent=spaces=4 --pad-header --pad-header --pad-header --align-pointer=name --lineend=linux --convert-tabs --verbose $changed_files
|
||||||
err=$?
|
err=$?
|
||||||
if [ $err -ne 0 ]; then
|
if [ $err -ne 0 ]; then
|
||||||
echo "[rt-thread][astyle] we found a obvious fault, please fix the error then commit again"
|
echo "[rt-thread][astyle] we found a obvious fault, please fix the error then commit again"
|
||||||
exit $err
|
exit $err
|
||||||
else
|
else
|
||||||
echo "[rt-thread][astyle] astyle file ok"
|
echo "[rt-thread][astyle] astyle file ok"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "astyle does not exist"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# We only filter the file name with c or cpp file.
|
# We only filter the file name with c or cpp file.
|
||||||
changed_files=$(git diff-index --cached $against | \
|
changed_files=$(git diff-index --cached $against | \
|
||||||
grep -E '[MA] .*\.(c|cpp|h)$' | cut -d' ' -f 2)
|
grep -E '[MA] .*\.(c|cpp|h)$' | cut -d' ' -f 2)
|
||||||
# formatting check
|
# formatting check
|
||||||
# https://github.com/mysterywolf/formatting
|
# https://github.com/mysterywolf/formatting
|
||||||
# formatting cmd ref https://github.com/supperthomas/git_auto_script
|
# formatting cmd ref https://github.com/supperthomas/git_auto_script
|
||||||
if [ -n "$changed_files" ]; then
|
if which formatting > /dev/null; then
|
||||||
formatting $changed_files
|
if [ -n "$changed_files" ]; then
|
||||||
echo "[rt-thread] formatting $changed_files is ok"
|
formatting $changed_files
|
||||||
git add $changed_files
|
echo "[rt-thread] formatting $changed_files is ok"
|
||||||
exit 0
|
git add $changed_files
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "formatting does not exist"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue