Files
tarpc/hooks/pre-push

43 lines
939 B
Plaintext
Executable File

# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
#!/bin/sh
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
git diff --exit-code &>/dev/null
if [ "$?" != 0 ];
then
echo ${RED}ERROR${NC} You have uncommitted changes please commit or stash them before pushing so that I can run tests!
exit 1
fi
printf "${YELLOW}[PRESUBMIT]${NC} Running tests ... "
TEST_RESULT=0
cargo test --manifest-path tarpc/Cargo.toml &>/dev/null
if [ "$?" != "0" ];
then
printf "${RED}FAILED${NC}"
TEST_RESULT=1
else
printf "${GREEN}ok${NC}"
fi
printf "\n"
RESULT=0
if [ "$TEST_RESULT" == "1" ];
then
RESULT=1
fi
exit $RESULT