Skip to content

Instantly share code, notes, and snippets.

@JulienBlancher
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JulienBlancher/573c8f1a29eac43aca7e to your computer and use it in GitHub Desktop.
Save JulienBlancher/573c8f1a29eac43aca7e to your computer and use it in GitHub Desktop.
Sample commit and dump BDD script
#/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
@JulienBlancher
Copy link
Author

Not updated anymore. See https://gitlab.com/snippets/2688

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment