2016-01-18 23:38:49 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-01-19 08:15:30 +00:00
|
|
|
DIR=`dirname $0`
|
2016-01-18 23:38:49 +00:00
|
|
|
EXIT_CODE=0
|
|
|
|
|
2016-01-19 08:15:30 +00:00
|
|
|
go build -o $DIR/spell-checker $DIR/spell-checker.go
|
2016-01-19 08:42:31 +00:00
|
|
|
|
2016-01-19 12:50:18 +00:00
|
|
|
cat $DIR/dictionary.dic | wc -l > $DIR/dictionary_custom.dic
|
|
|
|
cat $DIR/dictionary.dic | sort >> $DIR/dictionary_custom.dic
|
|
|
|
|
2016-01-19 08:42:31 +00:00
|
|
|
git diff HEAD^ --name-status | grep "^D" -v | awk '{print $2}' > changed_files
|
2016-01-18 23:38:49 +00:00
|
|
|
|
|
|
|
while read FILE; do
|
|
|
|
echo -n "Проверка файла $FILE на опечатки... ";
|
|
|
|
|
2016-01-19 12:50:18 +00:00
|
|
|
OUTPUT_RU=$(cat "$FILE" | sed 's/https\?:[^ ]*//g' | sed "s/[(][^)]*\.md[)]//g" | hunspell -d russian-aot,ru_RU,en_US,de_DE,$DIR/dictionary_custom | $DIR/spell-checker);
|
2016-01-18 23:38:49 +00:00
|
|
|
RU_EXIT_CODE=$?
|
2016-01-19 12:50:18 +00:00
|
|
|
OUTPUT_EN=$(cat "$FILE" | sed 's/https\?:[^ ]*//g' | sed "s/[(][^)]*\.md[)]//g" | hunspell -d en_US,russian-aot,ru_RU,de_DE,$DIR/dictionary_custom | $DIR/spell-checker);
|
2016-01-18 23:38:49 +00:00
|
|
|
EN_EXIT_CODE=$?
|
2016-01-19 12:50:18 +00:00
|
|
|
OUTPUT_DE=$(cat "$FILE" | sed 's/https\?:[^ ]*//g' | sed "s/[(][^)]*\.md[)]//g" | hunspell -d de_DE,en_US,russian-aot,ru_RU,$DIR/dictionary_custom | $DIR/spell-checker);
|
2016-01-19 09:46:22 +00:00
|
|
|
DE_EXIT_CODE=$?
|
2016-01-18 23:38:49 +00:00
|
|
|
|
2016-01-19 09:46:22 +00:00
|
|
|
if [ $RU_EXIT_CODE -ne 0 ] || [ $EN_EXIT_CODE -ne 0 ] || [ $DE_EXIT_CODE -ne 0 ]; then
|
2016-01-18 23:38:49 +00:00
|
|
|
EXIT_CODE=1;
|
|
|
|
echo "ошибка";
|
2016-01-19 12:50:18 +00:00
|
|
|
echo "$OUTPUT_RU\n$OUTPUT_DE\n$OUTPUT_EN" | sort -n -k2 | uniq;
|
2016-01-18 23:38:49 +00:00
|
|
|
else
|
|
|
|
echo "пройдена";
|
|
|
|
fi
|
2016-01-19 08:42:31 +00:00
|
|
|
|
|
|
|
echo
|
2016-01-18 23:38:49 +00:00
|
|
|
done < changed_files
|
|
|
|
|
2016-01-19 08:52:01 +00:00
|
|
|
exit $EXIT_CODE
|