-
-
Save cabello/416baa581631779d991b88c265b209aa to your computer and use it in GitHub Desktop.
git commit hooks
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
[core] | |
excludesfile = /Users/foo/workspace/private/dotfiles/.gitignore_global | |
hooksPath = /Users/foo/workspace/private/dotfiles/.git-templates/hooks |
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
.idea/ | |
.DS_Store | |
.env | |
.vsTODO | |
TODO | |
.rbenv-gemsets | |
spec/examples.txt | |
.overcommit.yml | |
.byebug_history | |
.vscode/ | |
knapsack_rspec_report.json | |
node_modules/ | |
.bundle/ | |
coverage_full/ | |
.scratch.md | |
jsconfig.json | |
# Compiled source # | |
################### | |
*.com | |
*.class | |
*.dll | |
*.exe | |
*.o | |
*.so | |
# Packages # | |
############ | |
# it's better to unpack these files and commit the raw source | |
# git has its own built in compression methods | |
*.7z | |
*.dmg | |
*.gz | |
*.iso | |
*.jar | |
*.rar | |
*.tar | |
*.zip | |
# Logs and databases # | |
###################### | |
*.log | |
*.sql | |
*.sqlite | |
# OS generated files # | |
###################### | |
.DS_Store | |
.DS_Store? | |
._* | |
.Spotlight-V100 | |
.Trashes | |
ehthumbs.db | |
Thumbs.db |
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/bash | |
[ "$SKIP_POST_CHECKOUT" = 1 ] && exit 0 | |
# Looks for changes to Gemfile[.lock] or package.json, and automates running bundle and other tasks. | |
# Does not run if your local branch is behind the remote. | |
# https://gist.github.com/stefansundin/82051ad2c8565999b914 | |
# post-checkout hook - looks for changes to Gemfile[.lock] or package.json, | |
# when you change branches, and if found, reinstalls the given packages every | |
# Exit early if this was only a file checkout, not a branch change ($3 == 1) | |
[[ $3 == 0 ]] && exit 0 | |
# Exit early if first checkout ever because nothing will have changed. | |
[[ $1 == '0000000000000000000000000000000000000000' ]] && exit 0 | |
oldRef=$1 | |
newRef=$2 | |
# Exit early if the local branch is behind the remote | |
LOCAL=$(git rev-parse @) | |
REMOTE=$(git rev-parse @{u} 2> /dev/null) | |
BASE=$(git merge-base @ @{u} 2> /dev/null) | |
if [[ "$LOCAL" != "$REMOTE" && "$LOCAL" = "$BASE" ]]; then | |
echo "You are behind origin, not running bundle/migrate post-checkout hook." | |
exit 1 | |
fi | |
function changed { | |
git diff --name-only $oldRef $newRef | grep "^$1" > /dev/null 2>&1 | |
} | |
if changed 'Gemfile.*'; then | |
echo "Gemfile changed, bundling" | |
bundle install | |
fi | |
if changed 'bower.json'; then | |
echo "bower.json changed, installing" | |
bower install | |
fi | |
if changed 'yarn.lock'; then | |
echo "yarn.lock changed, installing" | |
yarn install | |
fi | |
if changed 'package.json' && test -e package-lock.json; then | |
echo "package.json changed, npm installing" | |
npm install | |
fi | |
if changed 'package.json' && test -e yarn.lock; then | |
echo "package.json changed, yarn installing" | |
yarn install | |
fi | |
if changed 'db/migrate'; then | |
echo "Migrations pending, migrating" | |
bundle exec rake db:create | |
bundle exec rake db:migrate RAILS_ENV=development RACK_ENV=development APP_ENV=development | |
bundle exec rake db:migrate RAILS_ENV=test RACK_ENV=test APP_ENV=test | |
fi |
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/bash | |
[ "$SKIP_POST_MERGE" = 1 ] && exit 0 | |
# Looks for changes to Gemfile[.lock] or package.json, and automates running bundle and other tasks. | |
# https://gist.github.com/stefansundin/82051ad2c8565999b914 | |
function changed { | |
git diff --name-only HEAD@{2} HEAD | grep "^$1" > /dev/null 2>&1 | |
} | |
if changed 'Gemfile.*'; then | |
echo "Gemfile changed, bundling" | |
bundle install | |
fi | |
if changed 'bower.json'; then | |
echo "bower.json changed, installing" | |
bower install | |
fi | |
if changed 'yarn.lock'; then | |
echo "yarn.lock changed, installing" | |
yarn install | |
fi | |
if changed 'package.json' && test -e package-lock.json; then | |
echo "package.json changed, npm installing" | |
npm install | |
fi | |
if changed 'package.json' && test -e yarn.lock; then | |
echo "package.json changed, yarn installing" | |
yarn install | |
fi | |
if changed 'db/migrate'; then | |
echo "Migrations pending, migrating" | |
bundle exec rake db:create | |
bundle exec rake db:migrate RAILS_ENV=development RACK_ENV=development APP_ENV=development | |
bundle exec rake db:migrate RAILS_ENV=test RACK_ENV=test APP_ENV=test | |
fi |
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/bash | |
if test -e .rubocop.yml; then | |
bundle exec rubocop | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment