Skip to content

Instantly share code, notes, and snippets.

@drymek
Last active December 25, 2015 01:39
Show Gist options
  • Save drymek/6896918 to your computer and use it in GitHub Desktop.
Save drymek/6896918 to your computer and use it in GitHub Desktop.
Notification when switching to git branches with different composer.lock source: http://www.markbadolato.com/blog/2013/08/23/notification-when-switchin-git-branches/
#!/bin/bash
# wget https://gist.github.com/drymek/6896918/raw -O /usr/share/git-core/templates/hooks/post-checkout
# chmod +x /usr/share/git-core/templates/hooks/post-checkout
# git init # to reload current git repository
PREV_COMMIT=$1
POST_COMMIT=$2
# MacOS Colors
NOCOLOR='\x1B[0m'
REDCOLOR='\x1B[37;41m'
# Linux Colors
#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 "\n${REDCOLOR} $NOCOLOR";
echo -e "${REDCOLOR} composer.lock has changed. You should run composer install $NOCOLOR";
echo -e "${REDCOLOR} $NOCOLOR\n";
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment