-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommit.sh
executable file
·97 lines (87 loc) · 2.2 KB
/
commit.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
############################################ VARIAVEIS
EMAIL_FROM="[email protected]"
USERNAME=git.ine5408
PASSWORD=quebragalho0
DATE=`date "+%Y-%m-%d %H:%M:%S"`
############################################ FUNCOES EMAIL
function sendEmail_exists() {
which sendEmail 1>/dev/null 2>&1
if [ $? -ne 0 ]
then
echo -e " O programa sendEmail deve ser instalado.\n Digite (como root) 'apt-get install libio-socket-ssl-perl libnet-ssleay-perl sendemail'."
exit 1
fi
}
function do_sendEmail() {
if [ -z "$SUBJECT" ]
then
echo "* "
echo "* Erro ao enviar e-mail (SUBJECT nao definido pelo comando 'git rev-parse')."
echo "* * *"
exit 1
fi
if [ -z "$MESSAGE" ]
then
echo "* "
echo "* Erro ao enviar e-mail (MESSAGE nao definido pelo comando 'git show')."
echo "* * *"
exit 1
fi
if [ -z "$AUTHOR" ]
then
echo "* "
echo "* Erro ao enviar e-mail (AUTHOR nao definido pelo comando 'git show')."
echo "* * *"
exit 1
fi
sendEmail -q -f $EMAIL_FROM -s smtp.gmail.com:587 -xu $USERNAME -xp $PASSWORD -t $EMAIL_TO -o tls=yes -u "$SUBJECT" -m "$MESSAGE"
if [ $? -ne 0 ]
then
echo "* "
echo "* Erro ao enviar e-mail (comando sendEmail)."
echo "* * *"
exit 1
fi
echo "* "
echo "* ..e-mail enviado com sucesso a: $EMAIL_TO."
echo "* * *"
}
########################################### INICIO DO SCRIPT
sendEmail_exists
while [ -z "$ENTRADA" ]
do
clear
echo "* * *"
echo "* COMMIT "
echo -n "* Comentario sobre o commit (max 300 caracteres): "
read -n 300 ENTRADA
done
echo "* Executando 'git commit -m \"$ENTRADA\"'"
git commit -m "$ENTRADA" .
if [ $? -ne 0 ]
then
echo "* "
echo "* Erro no comando 'git commit', abortando."
echo "* * *"
exit 1
fi
echo "* Executando 'git push origin master'"
git push origin master
if [ $? -ne 0 ]
then
echo "* "
echo "* Erro no comando 'git push origin master', abortando."
echo "* * *"
exit 1
fi
echo "* "
echo "* Commit feito e enviado para o github.com com sucesso."
echo "* * *"
echo "* * *"
echo "* Enviando e-mail.."
MESSAGE="$(git show)"
AUTHOR="$(git show | grep "^Author: " | cut -f2 -d":" | cut -f1 -d"<")"
SUBJECT="$DATE - $AUTHOR - $(git rev-parse HEAD)"
do_sendEmail