0

I am using github3 python API and I have this piece of code:

# Create new PR or get existing one
prs = [pr for pr in repo.iter_pulls(state="open", base="master",
                                    head="rev_testrev2")]
if len(prs) > 0:
    pr = prs[0]
else:
    pr = repo.create_pull("My pull request", "master", "rev_testrev2",
                          "This is a test pull request")
comments = [c for c in pr.iter_comments()]
print str(comments)

In the PR, in github web page, I have several comments in the "conversation" tab and just 1 in "Files Changed" tab.

The code above only prints the comments made in the "Files Changed" tab, which are associated with a file changed on a commit.

How do I list or create a PR comment created in the "Conversation" tab?

mvallebr
  • 2,388
  • 21
  • 36

1 Answers1

1

You can't list all of the comments on a Pull Request at once if I remember correctly. That said, you can get review comments with iter_comments as you're already doing.

It's important to keep in mind that as far as GitHub is concerned, pull requests are just issues with a little extra on top. So to get the comments in the conversation tab, you need to use iter_issue_comments.

print(list(pr.iter_issue_comments()))
Ian Stapleton Cordasco
  • 26,944
  • 4
  • 67
  • 72
  • This was not working with a prior version of the API, that's why it was so confusing to me. But I tried now and it worked fine, thanks! – mvallebr Jul 13 '15 at 11:02
  • You're welcome. Do you mean it didn't work with a previous version of github3? – Ian Stapleton Cordasco Jul 13 '15 at 12:05
  • Yes, I had tried to call this same method and it wasn't working. I changed the environment and it started working. – mvallebr Jul 13 '15 at 12:18
  • Actually not sure if it was a prior version of the github3 itself, but it was something in the environment for sure. Does this API work with some sort of local cache or something? It wasn't the first time something like this happened using it, I've had a similar problem checking the existence of a branch which had already been deleted – mvallebr Jul 13 '15 at 12:20
  • 1
    Pre 1.0 versions don't officially support caching. If someone is using it then they're accessing private attributes – Ian Stapleton Cordasco Jul 13 '15 at 12:22