Skip to content

Instantly share code, notes, and snippets.

@frak
Forked from lyrixx/post-checkout
Last active November 14, 2017 15:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frak/7579223 to your computer and use it in GitHub Desktop.
Save frak/7579223 to your computer and use it in GitHub Desktop.
Check for new dependencies and/or parameters after 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='\033[0m'
REDCOLOR='\033[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
if [[ -f app/config/parameters.yml.dist ]]; then
DIFF=`git diff --shortstat $PREV_COMMIT..$POST_COMMIT app/config/parameters.yml.dist`
if [[ $DIFF != "" ]]; then
echo -e "$REDCOLOR parameters.yml.dist has changed. You must run composer install $NOCOLOR"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment