Skip to content

Instantly share code, notes, and snippets.

@jsifalda
Last active January 4, 2017 16:04
Show Gist options
  • Save jsifalda/4442254 to your computer and use it in GitHub Desktop.
Save jsifalda/4442254 to your computer and use it in GitHub Desktop.
Run phpUnit tests before commit
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
echo "[PRECOMMIT HOOK] Running tests"
if [[ -e "libs/bin/phpunit" ]]; then
if [[ -d "tests" ]]; then
cd tests
../libs/bin/phpunit .
# phpunit . #if you have got a global phpunit
echo "\n"
else
echo "Folder './tests' does not exist"
fi
else
echo "libs/bin/phpunit does not exist"
fi
# Global setting - for all repositories
# git config --global init.templatedir '~/.git_template'
# Afterward, new repositories you create or clone will use this directory for templates.
# Place the hooks you want in ~/.git_template/hooks. Existing repositories can be reinitialized with the proper templates by running git init in the same directory .git is in.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment