You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/02/26 04:45:31 UTC
[incubator-nuttx] branch master updated: ci/tools: add rustfmt to checkfmt and ci config
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new b13fa5f ci/tools: add rustfmt to checkfmt and ci config
b13fa5f is described below
commit b13fa5fc055d774f80c167e437812443f60bbc6c
Author: Piet <pt...@mailbox.org>
AuthorDate: Sat Feb 26 00:06:47 2022 +0100
ci/tools: add rustfmt to checkfmt and ci config
---
tools/checkpatch.sh | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/tools/checkpatch.sh b/tools/checkpatch.sh
index 5e08b2a..a3f25ab 100755
--- a/tools/checkpatch.sh
+++ b/tools/checkpatch.sh
@@ -42,15 +42,37 @@ usage() {
exit $@
}
-check_file() {
- if ! $TOOLDIR/nxstyle $@ 2>&1; then
- fail=1
+is_rust_file() {
+ file_ext=${@##*.}
+ file_ext_r=${file_ext/R/r}
+ file_ext_rs=${file_ext_r/S/s}
+
+ if [ "$file_ext_rs" == "rs" ]; then
+ echo 1
+ else
+ echo 0
fi
+}
- if [ $spell != 0 ]; then
- if ! codespell -q 7 ${@: -1}; then
+check_file() {
+ if [ "$(is_rust_file $@)" == "1" ]; then
+ if ! command -v rustfmt &> /dev/null; then
+ fail=1
+ else
+ if ! rustfmt --edition 2021 --check $@ 2>&1; then
+ fail=1
+ fi
+ fi
+ else
+ if ! $TOOLDIR/nxstyle $@ 2>&1; then
fail=1
fi
+
+ if [ $spell != 0 ]; then
+ if ! codespell -q 7 ${@: -1}; then
+ fail=1
+ fi
+ fi
fi
}