Last active
August 29, 2015 14:07
-
-
Save JulienBlancher/573c8f1a29eac43aca7e to your computer and use it in GitHub Desktop.
Sample commit and dump BDD script
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 | |
# Constants | |
DB_NAME= | |
MYSQL_USER= | |
MYSQL_PASS= | |
ABS_PROJECT_ROOT= | |
DUMP_FILENAME=dump-sql-`date +%y-%m-%d-%T`.sql | |
COMMIT_MSG=$1 | |
MYSQLDUMP_BIN=`which mysqldump` | |
printf '\033[0;33;40m' | |
echo "Going to commit." | |
printf '\033[0m' | |
test_return () { | |
if [ $? -ne 0 ]; then | |
printf '\033[0;31;40m' | |
echo "An error occured. Exiting now." | |
printf '\033[0m' | |
exit 1 | |
fi | |
} | |
while [ -z "$COMMIT_MSG" ] | |
do | |
#printf '\033[0;31;40m' | |
echo "Please enter a commit message:" | |
#printf '\033[0m' | |
read COMMIT_MSG | |
done | |
cd $ABS_PROJECT_ROOT | |
test_return | |
rm dump-*.sql | |
$MYSQLDUMP_BIN -u $MYSQL_USER -p$MYSQL_PASS $DB_NAME > $DUMP_FILENAME | |
test_return | |
git status | |
test_return | |
printf '\033[0;33;40m' | |
echo "Git add in 3s" | |
printf '\033[0m' | |
sleep 3 | |
git add --all | |
test_return | |
git status | |
printf '\033[0;33;40m' | |
echo "Git commit in 2s" | |
printf '\033[0m' | |
sleep 2 | |
git commit -m "$COMMIT_MSG" | |
test_return | |
printf '\033[0;33;40m' | |
echo "Git push in 1 s" | |
printf '\033[0m' | |
git push | |
test_return | |
printf '\033[0;32;40m' | |
echo "Success ! End off the script :)" | |
printf '\033[0m' | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not updated anymore. See https://gitlab.com/snippets/2688