diff --git a/README.md b/README.md index df04849..1a1b03e 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,20 @@ with: ignore_words_list: abandonned,ackward ``` +### Parameter: uri_ignore_words_list + +Comma-separated list of words which will be ignored by `codespell` in URIs and emails only. +Words are case sensitive based on how they are written in the dictionary file. +If set to "*", all misspelling in URIs and emails will be ignored. + +This parameter is optional; by default `codespell` will check all URIs and emails for typos. + +``` +uses: codespell-project/actions-codespell@master +with: + uri_ignore_words_list: abandonned +``` + ### Parameter: path Indicates the path to run `codespell` in. diff --git a/action.yml b/action.yml index 522d9cf..59e4372 100644 --- a/action.yml +++ b/action.yml @@ -30,6 +30,10 @@ inputs: description: 'Comma-separated list of words to be ignored. Words are case sensitive based on how they are written in the dictionary file' required: false default: '' + uri_ignore_words_list: + description: 'comma separated list of words to be ignored in URIs and emails only' + required: false + default: '' path: description: 'Path to run codespell in' required: false diff --git a/entrypoint.sh b/entrypoint.sh index 0fc188f..7c3d4ed 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -40,6 +40,10 @@ echo "Ignore words list '${INPUT_IGNORE_WORDS_LIST}'" if [ "x${INPUT_IGNORE_WORDS_LIST}" != "x" ]; then command_args="${command_args} --ignore-words-list ${INPUT_IGNORE_WORDS_LIST}" fi +echo "Ignore URI words list '${INPUT_URI_IGNORE_WORDS_LIST}'" +if [ "x${INPUT_URI_IGNORE_WORDS_LIST}" != "x" ]; then + command_args="${command_args} --uri-ignore-words-list ${INPUT_URI_IGNORE_WORDS_LIST}" +fi echo "Resulting CLI options ${command_args}" exec 5>&1 res=`{ { codespell --count ${command_args} ${INPUT_PATH}; echo $? 1>&4; } 1>&5; } 4>&1` diff --git a/test/test.bats b/test/test.bats index db7ac8f..119bc5b 100644 --- a/test/test.bats +++ b/test/test.bats @@ -7,12 +7,13 @@ # This currently breaks the tests, so only enabling when troubleshooting #load teardown -ROOT_MISSPELLING_COUNT=5 +ROOT_MISSPELLING_COUNT=6 FILENAME_MISSPELLING_COUNT=1 HIDDEN_MISSPELLING_COUNT=1 EXCLUDED_MISSPELLING_COUNT=1 BUILTIN_NAMES_MISSPELLING_COUNT=1 IGNORE_WORDS_MISSPELLING_COUNT=5 +URI_IGNORE_WORDS_MISSPELLING_COUNT=1 SUBFOLDER_MISSPELLING_COUNT=1 # From all files called example.txt EXAMPLE_MISSPELLING_COUNT=5 @@ -40,6 +41,7 @@ function setup() { export INPUT_BUILTIN="" export INPUT_IGNORE_WORDS_FILE="" export INPUT_IGNORE_WORDS_LIST="" + export INPUT_URI_IGNORE_WORDS_LIST="" export INPUT_PATH="./test/testdata" export INPUT_ONLY_WARN="" } @@ -103,7 +105,7 @@ function setup() { } @test "Check the skip option" { - errorCount=$((ROOT_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT - EXAMPLE_MISSPELLING_COUNT)) + errorCount=$((ROOT_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT - EXAMPLE_MISSPELLING_COUNT - URI_IGNORE_WORDS_MISSPELLING_COUNT)) # codespell's exit status is 0, or 65 if there are errors found if [ $errorCount -eq 0 ]; then expectedExitStatus=0; else expectedExitStatus=65; fi INPUT_SKIP="example.txt" @@ -142,6 +144,16 @@ function setup() { [ "${lines[-4 - $errorCount]}" == "$errorCount" ] } +@test "Use a URI ignore words list" { + errorCount=$((ROOT_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT - URI_IGNORE_WORDS_MISSPELLING_COUNT)) + # codespell's exit status is 0, or 65 if there are errors found + if [ $errorCount -eq 0 ]; then expectedExitStatus=0; else expectedExitStatus=65; fi + INPUT_URI_IGNORE_WORDS_LIST="bu" + run "./entrypoint.sh" + [ $status -eq $expectedExitStatus ] + [ "${lines[-4 - $errorCount]}" == "$errorCount" ] +} + @test "Custom path" { errorCount=$((SUBFOLDER_MISSPELLING_COUNT)) # codespell's exit status is 0, or 65 if there are errors found diff --git a/test/testdata/example.txt b/test/testdata/example.txt index e1118f6..f27e93b 100644 --- a/test/testdata/example.txt +++ b/test/testdata/example.txt @@ -2,3 +2,4 @@ Abandonned ABANDONNED AbAnDoNnEd +https://www.bu.edu