diff --git a/check_migrations.sh b/check_migrations.sh index 31f042207..ff545a3c5 100755 --- a/check_migrations.sh +++ b/check_migrations.sh @@ -1,5 +1,15 @@ #!/bin/bash +# TODO: Após migrar para Django 1.10 usar +# +# ./manage.py makemigrations --check --dry-run +# +# ATENÇÃO: a chamada atual termina com exit 1 se NÃO HÁ migração a ser aplicada +# ou seja, termina com "erro" se está tudo bem! +# A chamada do django 1.10 INVERTE ISSO. +# +# https://docs.djangoproject.com/en/1.10/ref/django-admin/#cmdoption-makemigrations-check + python manage.py makemigrations --dry-run --exit MIGRATIONS=$? @@ -7,11 +17,10 @@ MIGRATIONS=$? NC='\033[0m' if [ $MIGRATIONS -eq 0 ]; then - RED='\033[0;31m' - echo -e "${RED}You have unapplied code changes. run 'python manage.py makemigrations' before submitting your code...${NC}" - exit 1 -else - GREEN='\033[0;32m' - echo -e "Working normally..." - exit 0 + RED='\033[0;31m' + echo + echo -e "${RED}ALGUMAS ALTERAÇÕES EXIGEM MIGRAÇÃO.${NC}" + echo -e "${RED}RODE 'python manage.py makemigrations' ANTES DE SUBMETER SEU CÓDIGO...${NC}" + echo + exit 1 fi \ No newline at end of file diff --git a/scripts/hooks/instalar_hooks_git.sh b/scripts/hooks/instalar_hooks_git.sh new file mode 100755 index 000000000..4c276b069 --- /dev/null +++ b/scripts/hooks/instalar_hooks_git.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +ln -s -f `pwd`/scripts/hooks/pre-commit .git/hooks/pre-commit + + diff --git a/scripts/hooks/pre-commit b/scripts/hooks/pre-commit new file mode 100755 index 000000000..3df8427d6 --- /dev/null +++ b/scripts/hooks/pre-commit @@ -0,0 +1,15 @@ +#!/bin/bash + +# aqui apenas reportamos, não impedimos o commit +./check_qa.sh +if [ $? -eq 1 ] +then + RED='\033[0;31m' + echo + echo -e "${RED}#### POR FAVOR, CORRIJA OS PROBLEMAS APONTADOS!!! ####${NC}" + echo +fi + +# se os comandos a seguir falharem impedimos o commit +set -e +./check_migrations.sh