toml 734 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env bash
  2. SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  3. source "${SCRIPTDIR}/.validate"
  4. IFS=$'\n'
  5. files=($(validate_diff --diff-filter=ACMR --name-only -- 'MAINTAINERS' || true))
  6. unset IFS
  7. badFiles=()
  8. for f in "${files[@]}"; do
  9. # we use "git show" here to validate that what's committed has valid TOML syntax
  10. if ! git show "$VALIDATE_HEAD:$f" | tomll /proc/self/fd/0; then
  11. badFiles+=("$f")
  12. fi
  13. done
  14. if [ ${#badFiles[@]} -eq 0 ]; then
  15. echo 'Congratulations! All TOML source files changed here have valid syntax.'
  16. else
  17. {
  18. echo "These files are not valid TOML:"
  19. for f in "${badFiles[@]}"; do
  20. echo " - $f"
  21. done
  22. echo
  23. echo 'Please reformat the above files as valid TOML'
  24. echo
  25. } >&2
  26. false
  27. fi