2021-10-18 13:48:08 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Fix common misspellings in text files (config: .codespellignore)
|
|
|
|
# Based on
|
|
|
|
# https://github.com/bitcoin/bitcoin/blob/master/test/lint/lint-spelling.sh
|
|
|
|
#
|
|
|
|
# We plan to replace this script with the `tools/lint` system as soon as we can.
|
|
|
|
|
|
|
|
IGNORE_WORDS_FILE=.codespellignore
|
2021-10-28 02:51:22 +02:00
|
|
|
if [ "$#" -eq 0 ]; then
|
2021-10-18 13:48:08 +02:00
|
|
|
echo "No argument specified. Checking on the entire repo..."
|
2022-08-30 22:37:49 +02:00
|
|
|
FILES_TO_BE_CHECKED="$(
|
|
|
|
git ls-files -- \
|
|
|
|
':!*.asc' \
|
|
|
|
':!*.svg' \
|
|
|
|
':!*/fixtures/*' \
|
|
|
|
':!docs/THIRDPARTY' \
|
|
|
|
':!docs/translating' \
|
|
|
|
':!locale' \
|
|
|
|
':!postgresql.conf.template.erb' \
|
|
|
|
':!tools/setup/emoji/emoji_map.json' \
|
|
|
|
':!tools/setup/emoji/emoji_names.py' \
|
2023-03-20 19:52:59 +01:00
|
|
|
':!pnpm-lock.yaml' \
|
2022-08-30 22:37:49 +02:00
|
|
|
':!zerver/management/data/unified_reactions.json'
|
|
|
|
)"
|
2021-10-28 02:51:22 +02:00
|
|
|
mapfile -t FILES_TO_BE_CHECKED <<<"$FILES_TO_BE_CHECKED"
|
2021-10-18 13:48:08 +02:00
|
|
|
else
|
2021-10-28 02:51:22 +02:00
|
|
|
FILES_TO_BE_CHECKED=("$@")
|
|
|
|
echo "Checking ${FILES_TO_BE_CHECKED[*]@Q}"
|
2021-10-18 13:48:08 +02:00
|
|
|
fi
|
|
|
|
|
2021-10-28 02:51:22 +02:00
|
|
|
if ! codespell --ignore-words="$IGNORE_WORDS_FILE" -- "${FILES_TO_BE_CHECKED[@]}"; then
|
2021-10-18 13:48:08 +02:00
|
|
|
echo "You may check the files for typo again using ./tools/run-codespell <file 1> <file 2> ... <file n>"
|
|
|
|
exit 1
|
|
|
|
fi
|