typos.bash 650 B

1234567891011121314151617181920212223
  1. #!/bin/sh
  2. set -e
  3. result=0
  4. echo "Running 'typos' on source code..."
  5. typos || result=1
  6. cfg='.typos.toml'
  7. tmp_cfg="${TEMP:-/tmp}/$cfg"
  8. # Uncomment `extend-ignore-identifiers-re` in the top-level config file
  9. # to make Git hashes (possibly used in commit messages) valid "identifiers".
  10. sed 's/^#\s*\(extend-ignore-identifiers-re\)/\1/' "$cfg" >"$tmp_cfg"
  11. if [ -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]; then
  12. for COMMIT in $(git rev-list "^$CI_MERGE_REQUEST_DIFF_BASE_SHA" "$CI_COMMIT_SHA"); do
  13. echo "Running 'typos' on commit message of $COMMIT..."
  14. git show --format=%B -s "$COMMIT" | typos -c "$tmp_cfg" - || result=1
  15. done
  16. fi
  17. exit $result