Created
June 25, 2014 21:56
-
-
Save jakeasmith/b696d9bcd027251a9304 to your computer and use it in GitHub Desktop.
Git hooks for running composer when things change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Put this file at: .git/hooks/post-checkout | |
# and make it executable | |
# You can install it system wide too, see http://stackoverflow.com/a/2293578/685587 | |
# Original source: http://nschoenmaker.nl/2013/07/composer-post-checkout-hook-in-git/ | |
PREV_COMMIT=$1 | |
POST_COMMIT=$2 | |
NOCOLOR='\e[0m' | |
REDCOLOR='\e[37;41m' | |
DIR=$(git rev-parse --show-toplevel) | |
if [[ -f composer.lock ]]; then | |
DIFF=`git diff --shortstat $PREV_COMMIT..$POST_COMMIT composer.lock` | |
if [[ $DIFF != "" ]]; then | |
echo -e "$REDCOLOR composer.lock has changed. Running composer install$NOCOLOR" | |
$DIR/composer.phar install --working-dir $DIR | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment