0

I am developing a tool to fetch all my pull requests and their dates in the repository of my organisation. How am I supposed to fetch pull requests raised from my account?

I have used pygithub and used the access token and login into my github account but could not fetch the pull requests of mine.

import os
from github import Github
my_token = "da0ab89dc50d9b2354e8f9c76*****74e0111"
ct_gh = Github(base_url="http://github.****.de/api/v3",login_or_token=my_token)
print("Connection to the server is done")
user_id = ct_gh.get_user()
print(user_id.name)

I am able to fetch my username and details but could not fetch the pull request numbers of mine.

dirkgroten
  • 20,112
  • 2
  • 29
  • 42
vignesh babu
  • 334
  • 3
  • 8

1 Answers1

0

Found a very normal way, and runs very slowly.

from github import Github

#url = your own url
#token = your own token
my_pr = list()
gh = Github(base_url=url, login_or_token=str(_token))
user = gh.get_user()
repos = user.get_repos()
for repo in repos:
    for pr in repo.get_pulls():
        if pr.user.name == user.name:
            my_pr.append(pr)

After this brute loop, all prs by your account are stored in my_pr, a list with PullRequest object.

qloveshmily
  • 1,017
  • 9
  • 5