Skip to content

Instantly share code, notes, and snippets.

@aelesbao
Last active December 12, 2015 04:49
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 aelesbao/4717353 to your computer and use it in GitHub Desktop.
Save aelesbao/4717353 to your computer and use it in GitHub Desktop.
git post-checkout hook that executes a "bundle install" if Gemfile has changes (using RVM if available)
#!/bin/bash --login
orig_commit=$1
dest_commit=$2
root="$(git rev-parse --show-toplevel 2> /dev/null)"
is_not_rebasing() {
test -d ${root}/.git/rebase-merge
}
is_gemfile_clean() {
git --no-pager diff --exit-code --name-only ${orig_commit} ${dest_commit} \
Gemfile Gemfile.lock > /dev/null
}
[[ -s .rvmrc ]] && . .rvmrc
is_not_rebasing && (is_gemfile_clean || bundle install)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment