Skip to content

Instantly share code, notes, and snippets.

@dealforest
Last active October 10, 2018 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dealforest/1774a21bf2307c2fe3e2 to your computer and use it in GitHub Desktop.
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/`
#!/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
@nezhyborets
Copy link

$perv on line 29 seems to be wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment