Created
March 19, 2013 19:30
-
-
Save avdgaag/5199350 to your computer and use it in GitHub Desktop.
Git post-checkout hook that automatically updates your bundled gems (if applicable), re-generates your tags index using exuberant ctags, and tries to advise you about pending migrations.
This file contains 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 | |
OLDREV=$1 | |
NEWREV=$2 | |
IS_BRANCH_CHECKOUT=$3 | |
function has_changes_to() { | |
git diff --name-only "$OLDREV" "$NEWREV" -- "$1" | grep "$1" > /dev/null | |
} | |
if [ -e Gemfile ]; then | |
echo '--> Checking Gem dependencies' | |
has_changes_to Gemfile || bundle check > /dev/null || ( | |
echo ' Running bundle install' | |
bundle install | grep 'Installing ' | |
) | |
fi | |
echo '--> Updating tags' | |
if [ -e Gemfile ]; then | |
echo ' Generating tags from bundled Gems' | |
bundle show --paths | xargs ctags -R 2>/dev/null | |
echo ' Generating project tags' | |
fi | |
/usr/local/bin/ctags -a --extra=+f --exclude=.git --exclude=log --exclude=tmp -R * 2>/dev/null | |
if [ -e db/schema.rb ]; then | |
echo '--> Checking for schema changes' | |
has_changes_to db/migrate || echo ' You have pending migrations. Run `rake db:migrate` to update your database.' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment