Created
October 3, 2013 18:00
-
-
Save alexmcroberts/6814174 to your computer and use it in GitHub Desktop.
Put the following content into the file at .git/hooks/post-merge in your git repository. It tells you if there any new files in a directory after merging another branch. This is extremely useful as shown below for Migrations to ensure your database is in the same state as the master branch. This could be applied to anything else like new bash sc…
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 | |
# | |
# This hook parses the Migrations directory and counts if there are any migrations to run. | |
# If there are no migrations, nothing will show - leaving the developer in peace :) | |
git log -m -1 --name-only --pretty="format:" &> new_migrations.log | |
COUNTER=0 | |
while read CMD; do | |
if [[ $CMD == *Migration* ]] | |
then | |
let COUNTER=COUNTER+1 | |
fi | |
done < new_migrations.log | |
if [[ $COUNTER > 0 ]] | |
then | |
printf '\033[0;32m%s\033[0m\n' ' _ _ _ _ _ _ _ _ _ _ ' | |
printf '\033[0;32m%s\033[0m\n' ' / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ ' | |
printf '\033[0;32m%s\033[0m\n' '( m | i | g | r | a | t | i | o | n | s )' | |
printf '\033[0;32m%s\033[0m\n' ' \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ ' | |
if [[ $COUNTER == 1 ]] | |
then | |
echo INFO: There is $COUNTER migration to run! | |
else | |
echo INFO: There are $COUNTER migrations to run! | |
fi | |
echo The command is: Console/cake migrations.migration run all | |
fi | |
rm new_migrations.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment