]> git.ipfire.org Git - thirdparty/squid.git/blob - scripts/spell-check.sh
MinGW-w64: enable native file locking (#1358)
[thirdparty/squid.git] / scripts / spell-check.sh
1 #!/bin/sh
2 #
3 ## Copyright (C) 1996-2023 The Squid Software Foundation and contributors
4 ##
5 ## Squid software is distributed under GPLv2+ license and includes
6 ## contributions from numerous individuals and organizations.
7 ## Please see the COPYING and CONTRIBUTORS files for details.
8 ##
9
10 #
11 # This script uses codespell to automatically fix a subset of common spelling
12 # mistakes in the current git-controlled workspace.
13 #
14 # Usage: ./scripts/spell-check.sh [target]...
15 # ... where "target" is a git-controlled file or directory name to be fixed.
16 #
17 # By default, a hand-picked subset of Squid repository sources is fixed.
18 #
19 # See ${ALLOW_LIST} below for the list of allowed misspellings.
20 #
21
22 set -e
23
24 echo -n "Codespell version: "
25 if ! codespell --version; then
26 echo "This script requires codespell which was not found."
27 exit 1
28 fi
29
30 if ! git diff --quiet; then
31 echo "There are unstaged changes. This script may modify sources."
32 echo "Stage changes to avoid permanent losses when things go bad."
33 exit 1
34 fi
35
36 IGNORE_LIST=scripts/codespell-ignorelist.txt
37 if test ! -f "${IGNORE_LIST}"; then
38 echo "${IGNORE_LIST} does not exist"
39 exit 1
40 fi
41
42 for FILENAME in `git ls-files "$@"`; do
43 # skip subdirectories, git ls-files is recursive
44 test -d $FILENAME && continue
45
46 case ${FILENAME} in
47
48 # skip (some) generated files with otherwise-checked extensions
49 doc/debug-sections.txt)
50 ;;
51
52 # skip imported/foreign files with otherwise-checked extensions
53 doc/*/*.txt)
54 ;;
55
56 # check all these
57 *.h|*.c|*.cc|*.cci|\
58 *.sh|\
59 *.pre|\
60 *.pl|*.pl.in|*.pm|\
61 *.dox|*.html|*.md|*.txt|\
62 *.sql|\
63 errors/templates/ERR_*|\
64 INSTALL|README|QUICKSTART)
65 if ! codespell -d -q 3 -w -I "${IGNORE_LIST}" ${FILENAME}; then
66 echo "codespell failed for ${FILENAME}"
67 exit 1
68 fi
69 ;;
70 esac
71 done
72
73 exit 0