github.com/nullne/docker@v1.13.0-rc1/hack/validate/swagger-gen (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 -- 'api/types/' || true) )
     8  unset IFS
     9  
    10  if [ ${#files[@]} -gt 0 ]; then
    11  	# We run vndr to and see if we have a diff afterwards
    12  	${SCRIPTDIR}/../generate-swagger-api.sh 2> /dev/null
    13  	# Let see if the working directory is clean
    14  	diffs="$(git status --porcelain -- api/types/ 2>/dev/null)"
    15  	if [ "$diffs" ]; then
    16  		{
    17  			echo 'The result of hack/geneate-swagger-api.sh differs'
    18  			echo
    19  			echo "$diffs"
    20  			echo
    21  			echo 'Please update api/swagger.yaml with any api changes, then '
    22  			echo 'run `hack/geneate-swagger-api.sh`.'
    23  		} >&2
    24  		false
    25  	else
    26  		echo 'Congratulations! All api changes are done the right way.'
    27  	fi
    28  else
    29      echo 'No api/types/ changes in diff.'
    30  fi