Skip to content

Commit f414fac

Browse files
authored
Merge pull request #202 from TheOneric/pull_backup-regular-comments
Backup regular pull request comments as well
2 parents 38692bc + b629a86 commit f414fac

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
@@ -907,6 +907,8 @@ def backup_pulls(args, repo_cwd, repository, repos_template):
907907
pulls = {}
908908
_pulls_template = '{0}/{1}/pulls'.format(repos_template,
909909
repository['full_name'])
910+
_issue_template = '{0}/{1}/issues'.format(repos_template,
911+
repository['full_name'])
910912
query_args = {
911913
'filter': 'all',
912914
'state': 'all',
@@ -946,10 +948,17 @@ def backup_pulls(args, repo_cwd, repository, repos_template):
946948

947949
log_info('Saving {0} pull requests to disk'.format(
948950
len(list(pulls.keys()))))
951+
# Comments from pulls API are only _review_ comments
952+
# regular comments need to be fetched via issue API.
953+
# For backwards compatibility with versions <= 0.41.0
954+
# keep name "comment_data" for review comments
955+
comments_regular_template = _issue_template + '/{0}/comments'
949956
comments_template = _pulls_template + '/{0}/comments'
950957
commits_template = _pulls_template + '/{0}/commits'
951958
for number, pull in list(pulls.items()):
952959
if args.include_pull_comments or args.include_everything:
960+
template = comments_regular_template.format(number)
961+
pulls[number]['comment_regular_data'] = retrieve_data(args, template)
953962
template = comments_template.format(number)
954963
pulls[number]['comment_data'] = retrieve_data(args, template)
955964
if args.include_pull_commits or args.include_everything:

0 commit comments

Comments
 (0)