1+ import argparse
12import os
23
3- import git
4-
54
65def get_changes (path ):
76 changes = ''
@@ -25,36 +24,27 @@ def get_changes(path):
2524 return changes .strip ()
2625
2726
28- bugfixes = get_changes ('changelog/unreleased/bugfixes/' )
29- features = get_changes ('changelog/unreleased/features/' )
30- issues = get_changes ('changelog/unreleased/issues/' )
31- other = get_changes ('changelog/unreleased/other/' )
32-
33- changelog = '#### Features\n ' + features + '\n \n ' + \
34- '#### Bug fixes and improvements\n ' + bugfixes + '\n \n ' + \
35- '#### Known issues :warning:\n ' + issues + '\n \n ' + \
36- '#### Other changes\n ' + other
37-
38- old_changelog = open ('changelog/unreleased/CHANGELOG.md' , 'r' ).read ()
27+ parser = argparse .ArgumentParser (description = 'Assemble changelog' )
28+ parser .add_argument ('--auto' , action = 'store_true' , help = 'To assemble android auto changelog' )
29+ args = parser .parse_args ()
3930
40- if changelog != old_changelog :
41- open ('changelog/unreleased/CHANGELOG.md' , 'w' ).write (changelog )
42- repository = git .Repo ('.' )
43- repository .git .add ('changelog/unreleased' )
44- repository .index .commit ('Assemble changelog file [skip ci]' )
45- repository .remotes .origin .push ().raise_if_error ()
31+ if args .auto :
32+ auto_bugfixes = get_changes ('libnavui-androidauto/changelog/unreleased/bugfixes/' )
33+ auto_features = get_changes ('libnavui-androidauto/changelog/unreleased/features/' )
4634
47- auto_bugfixes = get_changes ( 'libnavui-androidauto/changelog/unreleased/bugfixes/' )
48- auto_features = get_changes ( 'libnavui-androidauto/changelog/unreleased/features/' )
35+ auto_changelog = '#### Features \n ' + auto_features + ' \n \n ' + \
36+ '#### Bug fixes and improvements \n ' + auto_bugfixes
4937
50- auto_changelog = '#### Features\n ' + auto_features + '\n \n ' + \
51- '#### Bug fixes and improvements\n ' + auto_bugfixes
38+ print (auto_changelog )
39+ else :
40+ bugfixes = get_changes ('changelog/unreleased/bugfixes/' )
41+ features = get_changes ('changelog/unreleased/features/' )
42+ issues = get_changes ('changelog/unreleased/issues/' )
43+ other = get_changes ('changelog/unreleased/other/' )
5244
53- auto_old_changelog = open ('libnavui-androidauto/changelog/unreleased/CHANGELOG.md' , 'r' ).read ()
45+ changelog = '#### Features\n ' + features + '\n \n ' + \
46+ '#### Bug fixes and improvements\n ' + bugfixes + '\n \n ' + \
47+ '#### Known issues :warning:\n ' + issues + '\n \n ' + \
48+ '#### Other changes\n ' + other
5449
55- if auto_changelog != auto_old_changelog :
56- open ('libnavui-androidauto/changelog/unreleased/CHANGELOG.md' , 'w' ).write (auto_changelog )
57- repository = git .Repo ('.' )
58- repository .git .add ('libnavui-androidauto/changelog/unreleased' )
59- repository .index .commit ('Assemble auto changelog file [skip ci]' )
60- repository .remotes .origin .push ().raise_if_error ()
50+ print (changelog )
0 commit comments