Last active
September 28, 2016 16:01
-
-
Save luzfcb/52256bc248793f215d3394bd499d7a9f to your computer and use it in GitHub Desktop.
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 | |
# coloque esse arquivo dentro da pasta .git/hooks/ no seu projeto | |
# e de permissao de execucao com: | |
# chmod +x .git/hooks/pre-commit | |
# | |
# funciona somente com django 1.8 | |
# necessita de algumas pequenas modificacoes para funcionar com django 1.10 | |
exec 1>&2 | |
if [ -z $VIRTUAL_ENV ]; then | |
cat <<\EOF | |
########################################### | |
verificador de migracoes django nao criadas | |
########################################### | |
Seu commit nao foi realizado!!!! | |
Por favor, carregue um virtualenv antes de fazer o commit | |
EOF | |
exit 1; | |
else | |
PATH=$VIRTUAL_ENV/bin:$PATH | |
fi | |
python manage.py makemigrations --dry-run --exit >/dev/null 2>&1 | |
if [ $? -eq 0 ]; | |
then | |
cat <<\EOF | |
########################################### | |
verificador de migracoes nao criadas | |
########################################### | |
Seu commit nao foi realizado!!!! | |
Existem migracoes que ainda nao foram criadas. Voce pode cria-las executando: | |
python manage.py makemigrations | |
nao esqueca de adicionar as novas migracoes no git antes de tentar commitar novamente | |
EOF | |
exit 1; | |
fi | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment