33# This script handles some basic QA checks on the source
44
55NOPOST=$1
6- LIBRARY_NAME=` hatch project metadata name`
7- LIBRARY_VERSION=` hatch version | awk -F " ." ' {print $1"."$2"."$3}' `
8- POST_VERSION=` hatch version | awk -F " ." ' {print substr($4,0,length($4))}' `
6+ LIBRARY_NAME=$( hatch project metadata name)
7+ LIBRARY_VERSION=$( hatch version | awk -F " ." ' {print $1"."$2"."$3}' )
8+ POST_VERSION=$( hatch version | awk -F " ." ' {print substr($4,0,length($4))}' )
9+ TERM=${TERM:= " xterm-256color" }
910
1011success () {
1112 echo -e " $( tput setaf 2) $1 $( tput sgr0) "
@@ -28,7 +29,7 @@ while [[ $# -gt 0 ]]; do
2829 ;;
2930 * )
3031 if [[ $1 == -* ]]; then
31- printf " Unrecognised option: $1 \n " ;
32+ printf " Unrecognised option: %s\n " " $1 " ;
3233 exit 1
3334 fi
3435 POSITIONAL_ARGS+=(" $1 " )
3940inform " Checking $LIBRARY_NAME $LIBRARY_VERSION \n"
4041
4142inform " Checking for trailing whitespace..."
42- grep -IUrn --color " [[:blank:]]$" --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO
43- if [[ $? -eq 0 ]]; then
43+ if grep -IUrn --color " [[:blank:]]$" --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO; then
4444 warning " Trailing whitespace found!"
4545 exit 1
4646else
4949printf " \n"
5050
5151inform " Checking for DOS line-endings..."
52- grep -lIUrn --color $' \r ' --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile
53- if [[ $? -eq 0 ]]; then
52+ if grep -lIUrn --color $' \r ' --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile; then
5453 warning " DOS line-endings found!"
5554 exit 1
5655else
5958printf " \n"
6059
6160inform " Checking CHANGELOG.md..."
62- cat CHANGELOG.md | grep ^${LIBRARY_VERSION} > /dev/null 2>&1
63- if [[ $? -eq 1 ]]; then
61+ if ! grep " ^${LIBRARY_VERSION} " CHANGELOG.md > /dev/null 2>&1 ; then
6462 warning " Changes missing for version ${LIBRARY_VERSION} ! Please update CHANGELOG.md."
6563 exit 1
6664else
6967printf " \n"
7068
7169inform " Checking for git tag ${LIBRARY_VERSION} ..."
72- git tag -l | grep -E " ${LIBRARY_VERSION} $"
73- if [[ $? -eq 1 ]]; then
70+ if ! git tag -l | grep -E " ${LIBRARY_VERSION} $" ; then
7471 warning " Missing git tag for version ${LIBRARY_VERSION} "
7572fi
7673printf " \n"
0 commit comments