From cec7949a39c267d21810fcba02a9a1b1f02ade3e Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Tue, 25 Feb 2020 03:28:05 -0600 Subject: [PATCH] tools/checkpatch.sh: Add code spell check to checkpatch.sh (#371) --- tools/checkpatch.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tools/checkpatch.sh b/tools/checkpatch.sh index 3b54d42b6d..45303dd238 100755 --- a/tools/checkpatch.sh +++ b/tools/checkpatch.sh @@ -20,15 +20,17 @@ TOOLDIR=$(dirname $0) fail=0 range=0 +spell=0 usage() { echo "USAGE: ${0} [options] [list|-]" echo "" echo "Options:" echo "-h" - echo "-r range check only (used with -p and -c)" + echo "-c spell check with codespell(install with: pip install codespell" + echo "-r range check only (used with -p and -g)" echo "-p (default)" - echo "-c " + echo "-g " echo "-f " echo "- read standard input mainly used by git pre-commit hook as below:" echo " git diff --cached | ./tools/checkpatch.sh -" @@ -40,6 +42,14 @@ check_file() { if [ $ret != 0 ]; then fail=$ret fi + + if [ $spell != 0 ]; then + codespell -q 7 ${@: -1} + ret=$? + if [ $ret != 0 ]; then + fail=$ret + fi + fi } check_ranges() { @@ -98,6 +108,9 @@ while [ ! -z "$1" ]; do usage exit 0 ;; + -c ) + spell=1 + ;; -r ) range=1 ;; @@ -106,7 +119,7 @@ while [ ! -z "$1" ]; do patches=$@ break ;; - -c ) + -g ) shift commits=$@ break