-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgitlog.sh
executable file
·197 lines (158 loc) · 3.27 KB
/
gitlog.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/bin/bash
## Author LinkinStar
# solve the space by IFS
IFS=`echo -en "\n\b"`
echo -en $IFS
SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
echo ${SHELL_FOLDER}
dir=${SHELL_FOLDER}'/../../../'
if [ -f "${dir}CHANGELOG.md" ];then
rm -f ${dir}CHANGELOG.md
touch ${dir}CHANGELOG.md
else
touch ${dir}CHANGELOG.md
fi
function printFeat(){
for i in ${feat[@]}
do
echo "- "$i >> ${dir}CHANGELOG.md
done
echo >> ${dir}CHANGELOG.md
}
function printFix(){
for i in ${fix[@]}
do
echo "- "$i >> ${dir}CHANGELOG.md
done
echo >> ${dir}CHANGELOG.md
}
function printOther(){
for i in ${other[@]}
do
echo "- "$i >> ${dir}CHANGELOG.md
done
echo >> ${dir}CHANGELOG.md
}
function printDocs(){
echo "document formats are not added to changelog"
}
function printStyle(){
echo "style formats are not added to changelog"
}
function printRefactor(){
for i in ${refactor[@]}
do
echo "- "$i >> ${dir}CHANGELOG.md
done
echo >> ${dir}CHANGELOG.md
}
function printTest(){
echo "test formats are not added to changelog"
}
function printChore(){
echo "chore formats are not added to changelog"
}
function checkLog(){
if [[ $1 == "feat"* ]]
then
feat[featIndex]=$1
let featIndex++
elif [[ $1 == "fix"* ]]
then
fix[fixIndex]=$1
let fixIndex++
elif [[ $1 == "docs"* ]]
then
docs[docsIndex]=$1
let docsIndex++
elif [[ $1 == "style"* ]]
then
style[styleIndex]=$1
let styleIndex++
elif [[ $1 == "refactor"* ]]
then
refactor[refactorIndex]=$1
let refactorIndex++
elif [[ $1 == "test"* ]]
then
test[testIndex]=$1
let testIndex++
elif [[ $1 == "chore"* ]]
then
test[choreIndex]=$1
let choreIndex++
else
other[otherIndex]=$1
let otherIndex++
fi
}
function printLog(){
if [[ $featIndex -ne 0 ]]; then
echo "### Features" >> ${dir}CHANGELOG.md
printFeat
fi
if [[ $fixIndex -ne 0 ]]; then
echo "### Bug Fixes" >> ${dir}CHANGELOG.md
printFix
fi
if [[ docsIndex -ne 0 ]]; then
printDocs
fi
if [[ styleIndex -ne 0 ]]; then
printDocs
fi
if [[ refactorIndex -ne 0 ]]; then
printDocs
fi
if [[ testIndex -ne 0 ]]; then
printDocs
fi
if [[ choreIndex -ne 0 ]]; then
printDocs
fi
if [[ $otherIndex -ne 0 ]]; then
echo "### Other Changes" >> ${dir}CHANGELOG.md
printOther
fi
feat=()
featIndex=0
fix=()
fixIndex=0
docs=()
docsIndex=0
style=()
styleIndex=0
refactor=()
refactorIndex=0
test=()
testIndex=0
chore=()
choreIndex=0
other=()
otherIndex=0
}
curDate=""
function checkDate()
{
if [[ $curDate = $1 ]]; then
return
fi
curDate=$1
printLog
echo >> ${dir}CHANGELOG.md
echo "## "$curDate >> ${dir}CHANGELOG.md
}
commitMessageList=`git log --after="2019-09-04" --date=format:'%Y-%m-%d' --pretty=format:'%cd%n%s'`
index=0
for i in ${commitMessageList[@]}
do
if [[ $index%2 -eq 0 ]]
then
checkDate $i
else
#echo "- "$i >> CHANGELOG.md
checkLog $i
fi
let index++
done
printLog