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/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 53d90c8205 tools/checkpatch: fix isort doesn't return error
53d90c8205 is described below
commit 53d90c82050c4a3cc23dc3d817b5cc9f7fa23955
Author: xuxingliang <[email protected]>
AuthorDate: Wed Oct 16 20:14:25 2024 +0800
tools/checkpatch: fix isort doesn't return error
Flag --diff will output the changes content.
Flag --check-only will return exit code. It can be used together with
--diff.
Run isort again to format the code in place, to make the behavior same as
before.
Signed-off-by: xuxingliang <[email protected]>
---
tools/checkpatch.sh | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/tools/checkpatch.sh b/tools/checkpatch.sh
index 4e591c3adf..50e7d30a49 100755
--- a/tools/checkpatch.sh
+++ b/tools/checkpatch.sh
@@ -83,9 +83,15 @@ check_file() {
fi
if [ ${@##*.} == 'py' ]; then
- black --check $@ || fail=1
- flake8 --config ${TOOLDIR}/../.github/linters/setup.cfg $@ || fail=1
- isort --settings-path ${TOOLDIR}/../.github/linters/setup.cfg $@ || fail=1
+ setupcfg="${TOOLDIR}/../.github/linters/setup.cfg"
+ black --check "$@" || fail=1
+ flake8 --config "${setupcfg}" "$@" || fail=1
+ isort --diff --check-only --settings-path "${setupcfg}" "$@"
+ if [ $? -ne 0 ]; then
+ # Format in place
+ isort --settings-path "${setupcfg}" "$@"
+ fail=1
+ fi
elif [ "$(is_rust_file $@)" == "1" ]; then
if ! command -v rustfmt &> /dev/null; then
fail=1