Skip to content

Instantly share code, notes, and snippets.

@jverdeyen
Last active November 29, 2019 07:31
Show Gist options
  • Save jverdeyen/9c0b247bb8b34c7fae514315db36a23e to your computer and use it in GitHub Desktop.
Save jverdeyen/9c0b247bb8b34c7fae514315db36a23e to your computer and use it in GitHub Desktop.
A pre-commit hook for https://github.com/phpro/grumphp when developing like the Yappa way http://tech.yappa.be/docker-php-development
#!/bin/sh
#
# Run the hook command.
# Note: this will be replaced by the real command during copy.
#
CONTAINER="php"
ROOT_DIR="/var/www/app"
GIT_USER=$(git config user.name)
GIT_EMAIL=$(git config user.email)
COMMIT_MSG_FILE=$1
# Fetch the GIT diff and format it as command input:
DIFF=$(git diff -r -p -m -M --full-index --staged | cat)
# Run GrumPHP
(cd "./" && echo "${DIFF}" | docker exec -i `docker-compose ps -q ${CONTAINER}` bash -c "cd ${ROOT_DIR} && ./vendor/bin/grumphp git:commit-msg --git-user='$GIT_USER' --git-email='$GIT_EMAIL' $COMMIT_MSG_FILE")
# Validate exit code of above command
RC=$?
if [ "$RC" != 0 ]; then
exit $RC;
fi
# Clean exit:
exit 0;
#!/bin/sh
#
# Run the hook command.
# Note: this will be replaced by the real command during copy.
#
CONTAINER="php"
ROOT_DIR="/var/www/app"
# Fetch the GIT diff and format it as command input:
DIFF=$(git diff -r -p -m -M --full-index --staged | cat)
# Run GrumPHP
(cd "./" && echo "${DIFF}" | docker exec -i `docker-compose ps -q ${CONTAINER}` bash -c "cd ${ROOT_DIR} && ./vendor/bin/grumphp git:pre-commit --ansi --skip-success-output")
# Validate exit code of above command
RC=$?
if [ "$RC" != 0 ]; then
exit $RC;
fi
# Clean exit:
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment