djekl
6/26/2013 - 1:37 PM

Git post checkout

Git post checkout

#!/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

PREV_COMMIT=$1
POST_COMMIT=$2

NOCOLOR='\e[0m'
REDCOLOR='\e[37;41m'

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. You must run composer install$NOCOLOR"
    fi
fi