codespell.bash 543 B

123456789101112131415161718192021
  1. #!/bin/sh
  2. set -e
  3. result=0
  4. # 'codespell' with no arguments adds a leading './' to all paths.
  5. # Avoid that by globbing top-level entries explicitly.
  6. shopt -s dotglob
  7. echo "Running 'codespell' on source code..."
  8. codespell * || result=1
  9. shopt -u dotglob
  10. if [ -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]; then
  11. for COMMIT in $(git rev-list "^$CI_MERGE_REQUEST_DIFF_BASE_SHA" "$CI_COMMIT_SHA"); do
  12. echo "Running 'codespell' on commit message of $COMMIT..."
  13. git show --format=%B -s "$COMMIT" | codespell - || result=1
  14. done
  15. fi
  16. exit $result