Last active
May 22, 2019 15:36
-
-
Save petitJAM/7f3cb7de846cbe1878d1f8b2945e03e2 to your computer and use it in GitHub Desktop.
Post-merge check for Rails things (migrations, gems, yarn packages)
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 | |
# https://gist.github.com/petitJAM/7f3cb7de846cbe1878d1f8b2945e03e2 | |
DIFF=`git diff --name-only HEAD@{1} HEAD` | |
YARN=`expr "$DIFF" : ".*package\.json.*"` | |
MIGRATE=`expr "$DIFF" : ".*db/migrate.*"` | |
BUNDLE=`expr "$DIFF" : ".*Gemfile*"` | |
BLINK='\e[5m' | |
RED='\033[0;31m' | |
NC='\033[0m' # No Color | |
if [ ! "$BUNDLE" -eq 0 ] || [ ! "$MIGRATE" -eq 0 ] || [ ! "$YARN" -eq 0 ] | |
then | |
echo -e "${BLINK}Hey! Listen!" | |
fi | |
if [ ! "$BUNDLE" -eq 0 ] | |
then | |
echo -e "${RED}There are changes in the Gemfile! Run 'bundle install'${NC}" | |
fi | |
if [ ! "$MIGRATE" -eq 0 ] | |
then | |
echo -e "${RED}There are new migrations! Run 'rails db:migrate'${NC}" | |
fi | |
if [ ! "$YARN" -eq 0 ] | |
then | |
echo -e "${RED}There are new JavaScript dependencies! Run 'yarn install'${NC}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This goes in
.git/hooks/post-merge
.