Skip to content

Commit

Permalink
Merge pull request #53 from djmattyg007/sorting-script
Browse files Browse the repository at this point in the history
Make it so that anyone can easily check the sorting of dictionary lists
  • Loading branch information
MichaelAquilina authored Aug 10, 2021
2 parents 0d1d37e + 8db66ba commit 1c146d8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
9 changes: 1 addition & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,7 @@ jobs:
command: black . --check
- run:
name: check word dictionaries are sorted
command: |
for file in "whitelist.txt" flake8_spellcheck/*.txt;
do
if [ "$(sort < "$file")" != "$(<"$file")" ]; then
echo "$file is not sorted correctly"
exit 1
fi
done
command: ./check-sorting.sh
- run:
name: yamllint
command: yamllint .
Expand Down
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ adding those word(s) to the appropriate dictionaries:
* `technical dictionary <flake8_spellcheck/technical.txt>`_
* `django dictionary <flake8_spellcheck/django.txt>`_

Before you submit a PR, it is recommended to run ``check-sorting.sh`` in the root of this repository,
to verify that all the dictionary files are still sorted correctly. Sorting is enforced by CI, so
you'll need to make sure the files are sorted before your PR can be merged.


.. |CircleCI| image:: https://circleci.com/gh/MichaelAquilina/flake8-spellcheck.svg?style=svg
:target: https://circleci.com/gh/MichaelAquilina/flake8-spellcheck
Expand Down
20 changes: 20 additions & 0 deletions check-sorting.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

cd "$(dirname "$0")"

# Sorting is locale-dependent, so force sort to use a locale that's always
# available for consistency.
export LC_ALL=C

all_sorted="true"

for file in "whitelist.txt" flake8_spellcheck/*.txt; do
if [[ "$(sort < "$file")" != "$(<"$file")" ]]; then
echo "$file is not sorted correctly" >&2
all_sorted="false"
fi
done

if [[ "$all_sorted" == "false" ]]; then
exit 1
fi

0 comments on commit 1c146d8

Please sign in to comment.