-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommitMessageGenerator.sh
More file actions
66 lines (66 loc) · 1.85 KB
/
commitMessageGenerator.sh
File metadata and controls
66 lines (66 loc) · 1.85 KB
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
#!/bin/bash
changedFiles=$(echo $(git diff --staged --name-only ) | tr " " ",")
if [[ $changedFiles == "" ]]
then
echo "No hay archivos preparados. Debes hacer primero git stage con los archivos que vas a agregar al commit."
exit 0
fi
flag=0
while [[ flag -eq 0 ]]
do
flag=1
read -p "Ingresa el tipo de commit ([B]ugfix, [F]eature, [H]otfix, [C]hore, [O]ther):" -n1 commitTypeInput
commitTypeUpper=$(echo $commitTypeInput | tr '[:lower:]' '[:upper:]')
if [[ $commitTypeUpper == "B" ]]
then
commitType="Bugfix"
elif [[ $commitTypeUpper == "F" ]]
then
commitType="Feature"
elif [[ $commitTypeUpper == "H" ]]
then
commitType="Hotfix"
elif [[ $commitTypeUpper == "C" ]]
then
commitType="Chore"
elif [[ $commitTypeUpper == "O" ]]
then
commitType="Other"
elif [[ $commitTypeUpper == "" ]]
then
flag=0
echo "Debes ingresar un tipo de commit"
else
flag=0
echo "\n$commitTypeInput no es una opción válida"
fi
done
commitMessage="${commitType}(${changedFiles}):"
echo "\n"
flag=0
while [[ flag -eq 0 ]]
do
flag=1
read -p "Ingresa la descripción del commit: " description
if [[ $description == "" ]]
then
flag=0
echo "Debes agregar una descripción"
fi
done
commitMessage="${commitMessage} ${description}"
read -p "Ingresa comentarios adicionales del commit separados por , (si no hay comentarios adicionales presiona enter): " comments
if [[ $comments != "" ]]
then
commentsFixed=$(echo $comments | tr , '\n')
commitMessage="${commitMessage}\n\n${commentsFixed}"
fi
read -p "Breaking changes (Si no hay breaking changes presiona enter): " breaking
if [[ $breaking == "" ]]
then
commitMessage="${commitMessage}\n\nNo breaking changes."
else
commitMessage="${commitMessage}\n\nBreaking changes: ${breaking}"
fi
echo "${commitMessage}" | pbcopy
echo "El mensaje para el commit fue copiado al portapapeles"