forked from nuttx/nuttx-update
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 <xuxingliang@xiaomi.com>
This commit is contained in:
parent
0d57e3dba6
commit
53d90c8205
1 changed files with 9 additions and 3 deletions
|
@ -83,9 +83,15 @@ check_file() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${@##*.} == 'py' ]; then
|
if [ ${@##*.} == 'py' ]; then
|
||||||
black --check $@ || fail=1
|
setupcfg="${TOOLDIR}/../.github/linters/setup.cfg"
|
||||||
flake8 --config ${TOOLDIR}/../.github/linters/setup.cfg $@ || fail=1
|
black --check "$@" || fail=1
|
||||||
isort --settings-path ${TOOLDIR}/../.github/linters/setup.cfg $@ || 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
|
elif [ "$(is_rust_file $@)" == "1" ]; then
|
||||||
if ! command -v rustfmt &> /dev/null; then
|
if ! command -v rustfmt &> /dev/null; then
|
||||||
fail=1
|
fail=1
|
||||||
|
|
Loading…
Reference in a new issue