github.com/olljanat/moby@v1.13.1/hack/validate/toml (about)

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