Skip to content

Commit b629a86

Browse files
committed
Backup regular pull request comments as well
Before, only review comments were backed up; regular comments need to be fetched via issue API. Fixes: #150
1 parent 63441eb commit b629a86

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

github_backup/github_backup.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,8 @@ def backup_pulls(args, repo_cwd, repository, repos_template):
902902
pulls = {}
903903
_pulls_template = '{0}/{1}/pulls'.format(repos_template,
904904
repository['full_name'])
905+
_issue_template = '{0}/{1}/issues'.format(repos_template,
906+
repository['full_name'])
905907
query_args = {
906908
'filter': 'all',
907909
'state': 'all',
@@ -941,10 +943,17 @@ def backup_pulls(args, repo_cwd, repository, repos_template):
941943

942944
log_info('Saving {0} pull requests to disk'.format(
943945
len(list(pulls.keys()))))
946+
# Comments from pulls API are only _review_ comments
947+
# regular comments need to be fetched via issue API.
948+
# For backwards compatibility with versions <= 0.41.0
949+
# keep name "comment_data" for review comments
950+
comments_regular_template = _issue_template + '/{0}/comments'
944951
comments_template = _pulls_template + '/{0}/comments'
945952
commits_template = _pulls_template + '/{0}/commits'
946953
for number, pull in list(pulls.items()):
947954
if args.include_pull_comments or args.include_everything:
955+
template = comments_regular_template.format(number)
956+
pulls[number]['comment_regular_data'] = retrieve_data(args, template)
948957
template = comments_template.format(number)
949958
pulls[number]['comment_data'] = retrieve_data(args, template)
950959
if args.include_pull_commits or args.include_everything:

0 commit comments

Comments
 (0)