import RT-Thread@9217865c without bsp, libcpu and components/net

This commit is contained in:
Zihao Yu 2023-05-20 16:23:33 +08:00
commit e2376a3709
1414 changed files with 390370 additions and 0 deletions

70
.hooks/pre-commit Normal file
View file

@ -0,0 +1,70 @@
#!/bin/sh
# AUTHOR: supperthomas
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi
# We only filter the file name with c or cpp file.
changed_files=$(git diff-index --cached $against | \
grep -E '[MA] .*\.(c|cpp|cc|cxx)$' | cut -d' ' -f 2)
if which cppcheck > /dev/null; then
if [ -n "$changed_files" ]; then
cppcheck --enable=warning,performance,portability --inline-suppr --error-exitcode=1 --platform=win64 --force $changed_files
err=$?
if [ $err -ne 0 ]; then
echo "[rt-thread][cppcheck] we found a obvious fault, please fix the error then commit again"
exit $err
else
echo "[rt-thread][cppcheck] cppcheck ok."
fi
fi
else
echo "cppcheck does not exist"
fi
# We only filter the file name with c or cpp or h file.
# astyle only astyle the added file[because of code reivewer], if you want change modify file, please use [MA]
changed_files=$(git diff-index --cached $against | \
grep -E '[MA] .*\.(c|cpp|h)$' | cut -d' ' -f 2)
if which astyle > /dev/null; 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
err=$?
if [ $err -ne 0 ]; then
echo "[rt-thread][astyle] we found a obvious fault, please fix the error then commit again"
exit $err
else
echo "[rt-thread][astyle] astyle file ok"
fi
fi
else
echo "astyle does not exist"
fi
# We only filter the file name with c or cpp file.
changed_files=$(git diff-index --cached $against | \
grep -E '[MA] .*\.(c|cpp|h)$' | cut -d' ' -f 2)
# formatting check
# https://github.com/mysterywolf/formatting
# formatting cmd ref https://github.com/supperthomas/git_auto_script
if which formatting > /dev/null; then
if [ -n "$changed_files" ]; then
formatting $changed_files
echo "[rt-thread] formatting $changed_files is ok"
git add $changed_files
exit 0
fi
else
echo "formatting does not exist"
fi
exit 0

15
.hooks/readme.md Normal file
View file

@ -0,0 +1,15 @@
# How to use git hook
## SDK install
Please use cmd `git config --local core.hooksPath .hooks` for git hooks local.
## git hooks使用注意事项
- hooks里面的要安装cppcheck和astyle以及formatting命令行才能使用如果想要去掉某个选项在pre-commit中注释掉相应的命令即可。
- 取消hook选项请使用命令`git config --unset --local core.hooksPath .hooks` 可以取消hook格式化文件
- 这个githook不敲命令是不生效的
- githook会用astyle格式化一些文件这个按照rt-thread coding-style里面的设置来的这里要注意如果之前文件没有经过astlye格式化的话会出现很多修改如果修改过多建议不用astyle进行格式化。
- formatting命令只针对`c|cpp|h` 文件并没有针对文件夹修改等。所以如果有SDK等不希望formatting的文件请先将hooks功能去掉commit之后再考虑使用hooks命令。
- 如果对git的pre-commit不是很熟悉建议可以先不用这个hooks。