6
6
import semantic_version
7
7
import yaml
8
8
import re
9
+ import os
9
10
from collections import defaultdict
10
11
11
12
with open ('scripts/change-types.yaml' , 'r' ) as f :
24
25
'fixdoc:' : typs ['fixdoc' ],
25
26
'dep:' : typs ['dep' ],
26
27
'ci:' : typs ['ci' ],
28
+ 'CI:' : typs ['ci' ],
27
29
28
30
# fix typo
29
31
'Change:' : typs ['api-change' ],
37
39
'new-features:' : typs ['new-feature' ],
38
40
'docs:' : typs ['doc' ],
39
41
'fix:' : typs ['fixbug' ],
42
+ 'Fix:' : typs ['fixbug' ],
40
43
'fixup:' : typs ['fixbug' ],
41
44
42
45
'test:' : typs ['test' ],
45
48
'Update:' : typs ['other' ],
46
49
'update:' : typs ['other' ],
47
50
'turn:' : typs ['other' ],
48
- 'replace:' : typs ['refactor' ],
49
- 'use:' : typs ['refactor' ],
50
- 'Create:' : typs ['other' ],
51
+ 'replace:' : typs ['refactor' ],
52
+ 'use:' : typs ['refactor' ],
53
+ 'Create:' : typs ['other' ],
54
+ 'BumpVer:' : typs ['other' ],
51
55
}
52
56
53
57
category_display = {
62
66
replace_subjects = [
63
67
(r'^([^: ]+) ' , r'\1: ' ), # add ":" if not
64
68
(r'^(\w+:) *' , r'\1 ' ), # 0 or many space to 1 space
65
- (r'^build\(dpes\): ' , r'dep: ' ),
69
+ (r'^build\(dpes\): ' , r'dep: ' ),
66
70
]
67
71
68
72
ignores = [
69
- '^Merge pull request' ,
73
+ '^Merge pull request' ,
74
+ '^BumpVer:' ,
70
75
]
71
76
72
77
to_display = {
73
- 'other' : False ,
78
+ 'other' : False ,
74
79
'doc' : False ,
75
80
'refactor' : False ,
76
81
'internal' : False ,
77
82
'test' : False ,
78
- 'ci' : False ,
83
+ 'ci' : False ,
79
84
}
80
85
81
86
commit_url_ptn = 'https://github.com/datafuselabs/openraft/commit/{hash}'
@@ -127,13 +132,13 @@ def changes(frm, to):
127
132
body = cmd (["git" , "log" , '-1' , '--format=%b' , commit ])
128
133
129
134
item = {
130
- 'hash' : commit ,
135
+ 'hash' : commit ,
131
136
'subject' : elts [0 ],
132
137
# 2019-04-18 13:36:42 +0800
133
138
'time' : elts [1 ].split ()[0 ],
134
139
'author' : elts [2 ],
135
140
'email' : elts [3 ],
136
- 'body' : body ,
141
+ 'body' : body ,
137
142
}
138
143
139
144
rst .append (item )
@@ -179,12 +184,12 @@ def norm_changes(changes):
179
184
bodylines = ch ['body' ].strip ().splitlines ()
180
185
bodylines = [' ' + x for x in bodylines ]
181
186
desc = {
182
- 'hash' : ch ['hash' ],
187
+ 'hash' : ch ['hash' ],
183
188
"content" : cont ,
184
189
"time" : ch ['time' ],
185
190
"author" : ch ['author' ],
186
191
'email' : ch ['email' ],
187
- 'body' : bodylines ,
192
+ 'body' : bodylines ,
188
193
}
189
194
c .append (desc )
190
195
@@ -196,6 +201,12 @@ def build_ver_changelog(new_ver, commit="HEAD"):
196
201
It will find out all commit since the last tag that is less than ``new_ver``
197
202
'''
198
203
204
+ fn = 'change-log/v{new_ver}.md' .format (new_ver = new_ver )
205
+ if os .path .exists (fn ):
206
+ print ("--- Version {new_ver} change log exists, skip..." .format (new_ver = new_ver ))
207
+ print ("--- To rebuild it, delete {fn} and re-run" .format (fn = fn ))
208
+ return
209
+
199
210
tags = list_tags ()
200
211
tags .sort ()
201
212
@@ -234,7 +245,7 @@ def build_ver_changelog(new_ver, commit="HEAD"):
234
245
235
246
changelog = '\n ' .join (lines )
236
247
237
- with open ('change-log/v{new_ver}.md' . format ( new_ver = new_ver ) , 'w' ) as f :
248
+ with open (fn , 'w' ) as f :
238
249
f .write (changelog )
239
250
240
251
def build_changelog ():
@@ -256,11 +267,11 @@ def build_changelog():
256
267
cont = cont .splitlines ()
257
268
cont = '\n ' .join (cont )
258
269
259
- f .write (cont + '\n ' )
270
+ f .write (cont + '\n \n ' )
260
271
261
272
if __name__ == "__main__" :
262
273
# Usage: to build change log from git log
263
- # ./scripts/build_change_log.py v0 .5.10
274
+ # ./scripts/build_change_log.py 0 .5.10
264
275
new_ver = sys .argv [1 ]
265
276
if len (sys .argv ) > 2 :
266
277
commit = sys .argv [2 ]
0 commit comments