Created
June 26, 2013 13:37
-
Star
(100)
You must be signed in to star a gist -
Fork
(16)
You must be signed in to fork a gist
-
-
Save lyrixx/5867424 to your computer and use it in GitHub Desktop.
Git post checkout
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 | |
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 |
Guys, is there any chance to run it on git pull/merge? In a nutshell, on any update.
Hook files as post-update
, post-receive
don't work.
I made this script for testing and it didn't show any red message.
git checkout 1.1.0
git branch -d master
git checkout 1.1.0 -b master
git branch --set-upstream-to=origin/master master
git pull
@andkirby don't forget to chmod +x
curl -Ls https://gist.githubusercontent.com/lyrixx/5867424/raw/0af090ab37d07a4d814c1ee2a267fad90767565d/post-checkout \
> "$(git rev-parse --git-dir)/hooks/post-checkout" && chmod +x "$(git rev-parse --git-dir)/hooks/post-checkout"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Quick download of this file from CLI: