Skip to content

Instantly share code, notes, and snippets.

Created March 20, 2014 00:25
Show Gist options
  • Save anonymous/9654749 to your computer and use it in GitHub Desktop.
Save anonymous/9654749 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Mar 20, 2014.
    32 changes: 32 additions & 0 deletions .git hooks post-merge
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #!/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: migrations run all
    fi

    rm new_migrations.log