Pygithub: API for Pull Request Checks?

Created on 10 Jul 2017  路  4Comments  路  Source: PyGithub/PyGithub

I'm trying to find a PR that has a specific failing check.

Is there a way to get information of the checks for a Pull Request?

Here is a screenshot:
pr_check

I didn't see anything obvious from the PR object:

g = Github("user", "password")
user = g.get_user()
org = g.get_organization('my_org')
repo = org.get_repo('myrepo')
for pr in repo.get_pulls():
    print(pr)
    for el in dir(pr):
        print(el)
    sys.exit()

Most helpful comment

The way I understand it, in the API statuses belong to commits, not to PRs per se. Try getting the last commit in a PR, and then using http://pygithub.readthedocs.io/en/latest/github_objects/Commit.html#github.Commit.Commit.get_statuses.

All 4 comments

The way I understand it, in the API statuses belong to commits, not to PRs per se. Try getting the last commit in a PR, and then using http://pygithub.readthedocs.io/en/latest/github_objects/Commit.html#github.Commit.Commit.get_statuses.

Cool. Good catch. Feel free to close this badboy then!
Thanks for looking into this!

One minor thing: It looks like you can now POST to create/update statuses:
https://developer.github.com/v3/repos/statuses/#create-a-status
It would be great if PyGithub supported this :)

@grayaii This is already there. You can use Commit.create_status method to create a status check for your PR. The trick however is you need to find the correct commit to create the status on.

This is what I did in one of my projects:

sha = pr.head.sha
repo.get_commit(sha=sha).create_status()
Was this page helpful?
0 / 5 - 0 ratings