#!/bin/bash # Save the file as /.git/hooks/pre-commit and chmod +x CWD=`pwd` MAIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ECLIPSE=/opt/eclipse/eclipse # Go to main project dir cd $MAIN_DIR/../../ # Run maven test MVN_RESULT=$(mvn test 2>&1) if [ $? -ne 0 ]; then >&2 echo "Unit test failure" cd $CWD exit 1 fi cd $CWD