-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconventional-commits-guide
executable file
·88 lines (69 loc) · 1.35 KB
/
conventional-commits-guide
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
#!/usr/bin/env bash
# enable interactive shell
exec < /dev/tty
types=("build" "chore" "ci" "docs" "feat" "fix" "perf" "refactor" "revert" "style" "test")
echo 'Select a type*:'
select type in "${types[@]}"; do
if [ $REPLY -gt "${#types[@]}" ]; then
echo 'Invalid type, try again...' >&2
else
break
fi
done
echo
echo "Scope:"
read scope
echo
while true; do
echo "Subject*:"
read subject
if [[ "$subject" != "" ]]; then
break
else
echo "This is a required field"
fi
done
echo
breakingchange=false
while true; do
read -n 1 -p "Is this a breaking change? [yN] " yn
case $yn in
[Yy]* ) breakingchange=true; break;;
[Nn]* ) break;;
"" ) break;;
* ) echo "Please answer yes or no.";;
esac
done
echo
echo
echo "Body:"
read body
echo
echo "Footer:"
read footer
# build message
typescoped="${type}"
if [[ "$scope" != "" ]]; then
typescoped="${type}(${scope})"
fi
message="${typescoped}: ${subject}"
if [[ "${body}" != "" ]]; then
message="${message}\n\n${body}"
fi
if $breakingchange || [[ "$footer" != "" ]]; then
message="${message}\n\n"
fi
if $breakingchange; then
message="${message}BREAKING CHANGE"
if [[ "${footer}" != "" ]]; then
message="${message}: "
fi
fi
if [[ "${footer}" != "" ]]; then
message="${message}${footer}"
fi
echo
echo Message:
echo -e $message
echo
echo -e $message > $1