From 1ee6a63fd6e9da6000648de48744ec0593e392a6 Mon Sep 17 00:00:00 2001 From: Adriano Date: Tue, 25 Feb 2020 18:03:19 -0300 Subject: [PATCH] Add git pre commit hook --- .githooks/pre-commit | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..5115131 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,42 @@ +#!/bin/sh + +# git config core.hooksPath .githooks + +echo "Running pre-commit checks at `pwd`" + +{ + echo "go vet ./..." + go vet ./... +} || { + exitStatus=$? + + if [ $exitStatus ]; then + printf "\ngo vet issues found in your code, please fix them and try again." + exit 1 + fi +} + +{ + echo "golint ./..." + golint ./... +} || { + exitStatus=$? + + if [ $exitStatus ]; then + printf "\nLint errors in your code, please fix them and try again." + exit 1 + fi +} + +{ + echo "go test ./..." + go test ./... +} || { + exitStatus=$? + + if [ $exitStatus ]; then + printf "\nTest errors in your code, please fix them and try again." + exit 1 + fi +} +