mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-25 00:14:02 +00:00
Add codespell wrappers : check.sh,changed_files.sh
Files adapted from the RIOT project : https://github.com/RIOT-OS/RIOT Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
This commit is contained in:
parent
6e7ea92d56
commit
8e0c6cd164
26
changed_files.sh
Normal file
26
changed_files.sh
Normal file
@ -0,0 +1,26 @@
|
||||
# Copyright 2017 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
# Copyright 2014 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
|
||||
# Copyright 2014 Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
|
||||
# Copyright 2020 Jonathan Demeyer <jona.dem@gmail.com>
|
||||
#
|
||||
# This file is subject to the terms and conditions of the GNU Lesser
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
|
||||
changed_files() {
|
||||
: ${FILEREGEX:='\.([CcHh])$'}
|
||||
: ${EXCLUDE:=''}
|
||||
: ${DIFFFILTER:='ACMR'}
|
||||
|
||||
DIFFFILTER="--diff-filter=${DIFFFILTER}"
|
||||
|
||||
# select either all or only touched-in-branch files, filter through FILEREGEX
|
||||
if [ -z "${BASE_BRANCH}" ]; then
|
||||
FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E ${FILEREGEX})"
|
||||
else
|
||||
FILES="$(git diff ${DIFFFILTER} --name-only ${BASE_BRANCH} | grep -E ${FILEREGEX})"
|
||||
fi
|
||||
|
||||
# filter out negatives
|
||||
echo "${FILES}" | grep -v -E ${EXCLUDE}
|
||||
}
|
55
check.sh
Normal file
55
check.sh
Normal file
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
#
|
||||
# This file is subject to the terms and conditions of the GNU Lesser
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
|
||||
CODESPELL_CMD="codespell"
|
||||
|
||||
if tput colors &> /dev/null && [ "$(tput colors)" -ge 8 ]; then
|
||||
CERROR=$'\033[1;31m'
|
||||
CRESET=$'\033[0m'
|
||||
else
|
||||
CERROR=
|
||||
CRESET=
|
||||
fi
|
||||
|
||||
: "${LWIPBASE:=$(cd $(dirname $0)/; pwd)}"
|
||||
cd $LWIPBASE
|
||||
|
||||
: "${LWIPTOOLS:=${LWIPBASE}}"
|
||||
. "${LWIPTOOLS}"/changed_files.sh
|
||||
|
||||
FILEREGEX='\.([CcHh]|sh|py|md|txt)$'
|
||||
EXCLUDE='^(./contrib/apps/LwipMibCompiler/Mibs)'
|
||||
FILES=$(FILEREGEX=${FILEREGEX} EXCLUDE=${EXCLUDE} changed_files)
|
||||
|
||||
if [ -z "${FILES}" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
${CODESPELL_CMD} --version &> /dev/null || {
|
||||
printf "%s%s: cannot execute \"%s\"!%s\n" "${CERROR}" "$0" "${CODESPELL_CMD}" "${CRESET}"
|
||||
exit 1
|
||||
}
|
||||
|
||||
CODESPELL_OPTS="-q 2" # Disable "WARNING: Binary file"
|
||||
CODESPELL_OPTS+=" --check-hidden"
|
||||
# Disable false positives "nd => and, 2nd", "ans => and", "tolen => token",
|
||||
# "ofo => of", "WAN => WANT", "mut => must, mutt, moot"
|
||||
CODESPELL_OPTS+=" --ignore-words-list=nd,ans,tolen,ofo,wan,mut"
|
||||
|
||||
# Filter-out all false positive raising "disabled due to" messages.
|
||||
ERRORS=$(${CODESPELL_CMD} ${CODESPELL_OPTS} ${FILES} | grep -ve "disabled due to")
|
||||
|
||||
if [ -n "${ERRORS}" ]
|
||||
then
|
||||
printf "%sThere are typos in the following files:%s\n\n" "${CERROR}" "${CRESET}"
|
||||
printf "%s\n" "${ERRORS}"
|
||||
# TODO: return 1 when all typos are fixed
|
||||
exit 0
|
||||
else
|
||||
exit 0
|
||||
fi
|
Loading…
Reference in New Issue
Block a user