Skip to content

Commit

Permalink
Testing pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JustAn0therDev committed Nov 18, 2021
1 parent 1b756ef commit 65b84d7
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions test-and-commit.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
OUTPUT=$(dotnet test)

SUCCESS=0
RESULT=0

while read -r LINE; do
echo $LINE
if [[ $LINE == *"Aprovado"* ]] || [[ $LINE == *"Passed"* ]]
then
SUCCESS=1
RESULT=1
break
elif [[ $LINE == *"MSB1003"* ]]
then
RESULT=2
break
fi

done <<< "$OUTPUT"

if [[ $SUCCESS == 1 ]]
if [[ $RESULT == 1 ]]
then
echo "Todos os testes passaram. Commit pode ser feito de forma segura."
elif [[ $RESULT == 2 ]]
then
read -p "Coloque sua mensagem de commit: " COMMIT
git add .
git commit -m "$COMMIT"
echo "Este projeto não possui testes."
else
echo "Não é possível realizar o commit pois um ou mais testes não passaram. Por favor, verifique o(s) projeto(s) de teste e tente novamente."
echo "Não é possível realizar commit pois alguns dos testes não passaram. Por favor, verifique o(s) projeto(s) de teste e tente novamente."
fi

echo $SUCCESS

0 comments on commit 65b84d7

Please sign in to comment.