Created
October 21, 2015 12:38
-
-
Save Patricy/a3bba1706e73c54df303 to your computer and use it in GitHub Desktop.
GIT hook for check after merge/pull. If some DB models (yaml) changed - it will notice user
This file contains hidden or 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 | |
| echo | |
| echo "============ Migration control v1.0 (by Patricy) 21-10-2015 ===============" | |
| RED='\033[1;31m' | |
| GREEN='\033[1;32m' | |
| NC='\033[0m' | |
| LOG_CHECK_PERIOD="1 month ago" | |
| SECONDS_CHECK=10 | |
| modelsPulled="$(git log --since="$LOG_CHECK_PERIOD" --pretty=format:"%h %ai" --name-only|grep yaml|while read line; do if [ -f $line ]; then DATE_LAST_MOD=`date -r $line +%s`; else DATE_LAST_MOD=0; fi;DATE_LAST_PULL=`date -r ./.git/FETCH_HEAD +%s`;COUNT=$(($DATE_LAST_PULL-$DATE_LAST_MOD));if [ $COUNT -lt $SECONDS_CHECK ]; then echo $line;fi;done|wc -l)" | |
| if [ $modelsPulled -gt 0 ]; then | |
| printf "${RED}ACHTUNG!!!! Perform migration!!!${NC}\n" | |
| else | |
| printf "${GREEN}No new models found for migration${NC}\n" | |
| fi | |
| echo "===========================================================================" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment