Created
December 11, 2020 09:42
-
-
Save ferminhg/ab7b552c0d4a0f7936c5d7823b729367 to your computer and use it in GitHub Desktop.
Get PR comments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create env | |
# python3.8 -mvenv venv | |
# activate | |
# . venv/bin/activate | |
# install lib https://github.com/PyGithub/PyGithub | |
# pip3 install PyGithub | |
# run | |
# python get-pr-comments.py > comments.json | |
from github import Github | |
import json | |
g = Github("access_token") | |
repo = g.get_repo("project") # project or org/project | |
pr = repo.get_pull(52) #id_of_pr | |
comments = pr.get_comments() | |
list_of_comments = [] | |
for comment in comments: | |
list_of_comments.append({ | |
'id': comment.id, | |
'url': comment.url, | |
'user': comment.user.login, | |
'path': comment.path, | |
'created_at': comment.updated_at.strftime("%Y/%m/%d, %H:%M:%S"), | |
'original_position': comment.original_position, | |
'body': comment.body, | |
}) | |
print(json.dumps(list_of_comments)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment