Copy the pre-commit file in .git/hooks/pre-commit and you'll never commit a non-working Go build again.
Last active
May 19, 2021 13:33
-
-
Save nl5887/dca1b363b8adc39984839de2808ed322 to your computer and use it in GitHub Desktop.
Git pre commit hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
DEST=$(mktemp -d) | |
SRC=$(pwd) | |
pushd . | |
cd $DEST; git clone --depth=1 $SRC/.git . >/dev/null 2>&1 | |
cd $SRC; git diff -P --cached | patch -p1 -d $DEST >/dev/null | |
cd $DEST; go build . | |
cd $DEST; go test ./... | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment