Files
tarpc/hooks/pre-push

36 lines
684 B
Bash
Executable File

#!/bin/sh
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
BRANCH=$(git symbolic-ref HEAD 2>/dev/null)
BRANCH_RESULT=$?
BRANCH=${BRANCH#refs/heads/}
if [ "$BRANCH_RESULT" != "0" ];
then
echo ${RED}ERROR${NC} You are not on a branch. Please check out a branch before pushing. Code: $BRANCH_RESULT
exit 1
fi
git diff --exit-code &>/dev/null
if [ "$?" != 0 ];
then
echo ${RED}ERROR${NC} You have uncommitted changes please commit or stash them before pushing.
exit 1
fi
cargo test &>/dev/null
if [ "$?" != "0" ];
then
echo ${GREEN}FAIL${NC} pre-push test check
else
echo ${GREEN}PASS${NC} pre-push test check
fi
if [ "$TEST_RESULT" == "1" ];
then
exit 1
fi
exit 0