Last active
October 10, 2018 15:10
-
-
Save dealforest/1774a21bf2307c2fe3e2 to your computer and use it in GitHub Desktop.
When you switch branch, run the `pod install`. install to `path/to/.git/hooks/`
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/sh | |
set -e | |
prev="$1" | |
new="$2" | |
branch_switch="$3" | |
if [ -z "$branch_switch" ] || [ $branch_switch -eq 0 ]; then | |
exit 0 # this was a file checkout | |
fi | |
if [ "$prev" = "$new" ]; then | |
exit 0 # this was same branch | |
fi | |
zero="0000000000000000000000000000000000000000" | |
if [ "$prev" = "$zero" ]; then | |
exit 0 # this was a clone | |
fi | |
if [ -d $HOME/.rbenv ]; then | |
export PATH="$HOME/.rbenv/bin:$PATH" | |
eval "$(rbenv init -)" | |
fi | |
cd `git rev-parse --show-toplevel` | |
diff=`git diff $perv $new --name-only | grep Podfile` | |
if [ -f "$PWD/Podfile" ] && [ -n $diff ]; then | |
echo 'run `pod install`' | |
echo -e "`pod install`" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$perv on line 29 seems to be wrong