1- import argparse
21import os
32
3+ import requests
4+
5+ pr_number = os .environ ['PR_NUMBER' ]
6+ token = os .environ ['GITHUB_TOKEN' ]
7+
48
59def get_changes (path ):
610 changes = ''
@@ -24,27 +28,36 @@ def get_changes(path):
2428 return changes .strip ()
2529
2630
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 ()
30-
31- if args .auto :
32- auto_bugfixes = get_changes ('libnavui-androidauto/changelog/unreleased/bugfixes/' )
33- auto_features = get_changes ('libnavui-androidauto/changelog/unreleased/features/' )
34-
35- auto_changelog = '#### Features\n ' + auto_features + '\n \n ' + \
36- '#### Bug fixes and improvements\n ' + auto_bugfixes
37-
38- print (auto_changelog )
31+ bugfixes = get_changes ('changelog/unreleased/bugfixes/' )
32+ features = get_changes ('changelog/unreleased/features/' )
33+ issues = get_changes ('changelog/unreleased/issues/' )
34+ other = get_changes ('changelog/unreleased/other/' )
35+
36+ changelog = '# Changelog' \
37+ '#### Features\n ' + features + '\n \n ' + \
38+ '#### Bug fixes and improvements\n ' + bugfixes + '\n \n ' + \
39+ '#### Known issues :warning:\n ' + issues + '\n \n ' + \
40+ '#### Other changes\n ' + other
41+
42+ # auto_bugfixes = get_changes('libnavui-androidauto/changelog/unreleased/bugfixes/')
43+ # auto_features = get_changes('libnavui-androidauto/changelog/unreleased/features/')
44+ #
45+ # auto_changelog = '#### Features\n' + auto_features + '\n\n' + \
46+ # '#### Bug fixes and improvements\n' + auto_bugfixes
47+ #
48+ # print(auto_changelog)
49+
50+ comments_url = 'https://api.github.com/repos/mapbox/mapbox-navigation-android/pulls/' + pr_number + '/comments'
51+ headers = {"Authorization" : "Bearer " + token }
52+ comments = requests .get (comments_url , headers = headers ).json ()
53+
54+ comment_with_changelog_id = None
55+ for comment in comments :
56+ if comment ['body' ].startswith ('# Changelog' ):
57+ comment_with_changelog_id = comment ['id' ]
58+
59+ if comment_with_changelog_id :
60+ comment_url = comments_url + '/' + comment_with_changelog_id
61+ requests .patch (comment_url , json = {'body' : changelog }, headers = headers )
3962else :
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/' )
44-
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
49-
50- print (changelog )
63+ requests .post (comments_url , json = {'body' : changelog }, headers = headers )
0 commit comments