Skip to content
Snippets Groups Projects
Commit ba2ee2c1 authored by Jan Frenzel's avatar Jan Frenzel
Browse files

Added a check for a sorted wordlist.aspell. Furthermore, made script

usable again for platforms where aspell does not have the markdown parameter.
parent 0c7797ee
No related branches found
No related tags found
3 merge requests!322Merge preview into main,!319Merge preview into main,!278Corrected mistake in spell checks related to git diff output; unified check-spelling.sh and check-spelling-changes.sh; added a few words to wordlist.aspell.
...@@ -7,6 +7,10 @@ basedir=`dirname "$scriptpath"` ...@@ -7,6 +7,10 @@ basedir=`dirname "$scriptpath"`
basedir=`dirname "$basedir"` basedir=`dirname "$basedir"`
wordlistfile=$(realpath $basedir/wordlist.aspell) wordlistfile=$(realpath $basedir/wordlist.aspell)
branch="origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-preview}" branch="origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-preview}"
aspellmode=
if aspell dump modes | grep -q markdown; then
aspellmode="--mode=markdown"
fi
function usage() { function usage() {
cat <<-EOF cat <<-EOF
...@@ -18,7 +22,7 @@ EOF ...@@ -18,7 +22,7 @@ EOF
} }
function getAspellOutput(){ function getAspellOutput(){
aspell -p "$wordlistfile" --ignore 2 -l en_US --mode=markdown list | sort -u aspell -p "$wordlistfile" --ignore 2 -l en_US $aspellmode list | sort -u
} }
function getNumberOfAspellOutputLines(){ function getNumberOfAspellOutputLines(){
...@@ -28,9 +32,16 @@ function getNumberOfAspellOutputLines(){ ...@@ -28,9 +32,16 @@ function getNumberOfAspellOutputLines(){
function isMistakeCountIncreasedByChanges(){ function isMistakeCountIncreasedByChanges(){
any_fails=false any_fails=false
#Unfortunately, sort depends on locale and docker does not provide much.
#Therefore, it uses bytewise comparison. We avoid problems with the command tr.
if ! sed 1d "$wordlistfile" | tr [:upper:] [:lower:] | sort -C; then
echo "Unsorted wordlist in $wordlistfile"
any_fails=true
fi
source_hash=`git merge-base HEAD "$branch"` source_hash=`git merge-base HEAD "$branch"`
#Remove everything except lines beginning with --- or +++ #Remove everything except lines beginning with --- or +++
files=`git diff $source_hash | sed -n 's#^[-+]\{3,3\} \(\(/\|./\)[^[:space:]]\+\)$#\1#p'` files=`git diff $source_hash | sed -E -n 's#^(---|\+\+\+) ((/|./)[^[:space:]]+)$#\2#p'`
#echo "$files" #echo "$files"
#echo "-------------------------" #echo "-------------------------"
#Assume that we have pairs of lines (starting with --- and +++). #Assume that we have pairs of lines (starting with --- and +++).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment