Skip to content

Instantly share code, notes, and snippets.

@arussellsaw
Created January 28, 2021 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arussellsaw/ffae08315d0d45c8111467020908a7a5 to your computer and use it in GitHub Desktop.
Save arussellsaw/ffae08315d0d45c8111467020908a7a5 to your computer and use it in GitHub Desktop.
go test your diff with emoji
#!/bin/bash
echo "⏱ pre-commit tests"
STAGED_GO_FILES=$(git diff HEAD --name-only -- '*.go')
> /tmp/testdirs
for file in $STAGED_GO_FILES; do
dir=$(dirname "$file")
echo "./$dir" >> /tmp/testdirs
done
if [ -s /tmp/testdirs ]
then
packages=$(cat /tmp/testdirs | sort| uniq)
echo "🎁 testing packages:"
echo "$packages"
gotestsum --hide-summary=skipped --format dots $packages
if [ $? -eq 0 ]
then
echo "✅ done"
exit 0
else
echo "❌ something went wrong 🤔"
exit 1
fi
else
echo "👀 nothing to test"
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment