Skip to content

Instantly share code, notes, and snippets.

@to4iki
Created November 12, 2014 06:42
Show Gist options
  • Save to4iki/270e454d5fece0202cb9 to your computer and use it in GitHub Desktop.
Save to4iki/270e454d5fece0202cb9 to your computer and use it in GitHub Desktop.
以下の設定を.git/hooks/以下のpost-checkoutファイルに書いてchmod +x post-checkoutしておけばブランチ切り替えごとにPodfileの更新があれば自動的にpod installするようになる。
#!/bin/sh
# parse this format
# x3de1b0 HEAD@{0}: checkout: moving from xxxx to yyyyy
BEFORE_BRANCH=`git reflog | head -1 | cut -f 6 -d ' '`
AFTER_BRANCH=`git reflog | head -1 | cut -f 8 -d ' '`
DIFF=`git diff ${BEFORE_BRANCH} ${AFTER_BRANCH} --name-only | grep Podfile`
if [ -n "${DIFF}" ]; then
bundle exec pod install # pod install
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment