diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ffc6e0b..9f9dd86 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -47,13 +47,38 @@ repos: args: - -c - | + FILE="spellcheck.dic" + + # Verify the first line is an integer. + first_line=$(head -n 1 "$FILE") + if ! [[ "$first_line" =~ ^[0-9]+$ ]]; then + echo "Error: The first line of $FILE must be an integer, but got: '$first_line'" + exit 1 + fi + expected_count="$first_line" + + # Verify the last line is completely empty (no spaces). + last_line=$(tail -n 1 "$FILE") + if [ -n "$last_line" ]; then + echo "Error: The last line of $FILE must be empty (without spaces)." + exit 1 + fi + + # Check that the number of lines between the first and last matches the integer. + # xargs (with no arguments) will strip leading/trailing whitespace from wc's output. + actual_count=$(sed '1d;$d' "$FILE" | wc -l | xargs) + if [ "$expected_count" -ne "$actual_count" ]; then + echo "Error: The number of lines between the first and last ($actual_count) does not match $expected_count." + exit 1 + fi + ( # Remove the first and last lines - sed '1d; $d' spellcheck.dic | LC_ALL=C sort -uc + sed '1d; $d' $FILE | LC_ALL=C sort -uc ) || { echo "Dictionary is not in sorted order. Correct order is:" # Show the correct order - LC_ALL=C sort -u <(sed '1d; $d' spellcheck.dic) + LC_ALL=C sort -u <(sed '1d; $d' $FILE) false } pass_filenames: false diff --git a/spellcheck.dic b/spellcheck.dic index b641390..3ffa409 100644 --- a/spellcheck.dic +++ b/spellcheck.dic @@ -1,4 +1,4 @@ -298 +301 & + 0o777 @@ -293,10 +293,11 @@ waker wakers wakeup wakeups +workstealing ~ ~12 ~4 ±1m ±1ms — -workstealing + diff --git a/utilities/init.sh b/utilities/init.sh index e2dc2b0..bcbb32c 100644 --- a/utilities/init.sh +++ b/utilities/init.sh @@ -45,4 +45,9 @@ mv cargo-spellcheck-v0.14.0-x86_64-unknown-linux-gnu cargo-spellcheck # install commitlint apt install -y nodejs npm -npm install --save-dev @commitlint/{cli,config-conventional} \ No newline at end of file +npm install --save-dev @commitlint/{cli,config-conventional} +npm install --save-dev husky +prefligit install # BEFORE npx husky init +npx husky init +echo "npx --no -- commitlint --edit \$1" > .husky/commit-msg +mv .git/hooks/pre-commit .husky/pre-commit \ No newline at end of file