File tree 1 file changed +48
-0
lines changed
1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+
3
+
4
+ import argparse
5
+ import json
6
+ import requests
7
+ import re
8
+
9
+
10
+ BASE_URL = 'https://api.github.com/repos/magicstack/uvloop/compare'
11
+
12
+
13
+ def main ():
14
+ parser = argparse .ArgumentParser (
15
+ description = 'Generate release log.' )
16
+ parser .add_argument ('--to' , dest = 'to_hash' , default = 'master' , type = str )
17
+ parser .add_argument ('--from' , dest = 'from_hash' , type = str )
18
+ args = parser .parse_args ()
19
+
20
+ r = requests .get (f'{ BASE_URL } /{ args .from_hash } ...{ args .to_hash } ' )
21
+ data = json .loads (r .text )
22
+
23
+ for commit in data ['commits' ]:
24
+ message = commit ['commit' ]['message' ]
25
+ first_line = message .partition ('\n \n ' )[0 ]
26
+ if commit .get ('author' ):
27
+ username = '@{}' .format (commit ['author' ]['login' ])
28
+ else :
29
+ username = commit ['commit' ]['author' ]['name' ]
30
+ sha = commit ["sha" ][:8 ]
31
+
32
+ m = re .search (r'\#(?P<num>\d+)\b' , message )
33
+ if m :
34
+ issue_num = m .group ('num' )
35
+ else :
36
+ issue_num = None
37
+
38
+ print (f'* { first_line } ' )
39
+ print (f' (by { username } in { sha } ' , end = '' )
40
+ if issue_num :
41
+ print (f' for #{ issue_num } )' )
42
+ else :
43
+ print (')' )
44
+ print ()
45
+
46
+
47
+ if __name__ == '__main__' :
48
+ main ()
You can’t perform that action at this time.
0 commit comments