-
Notifications
You must be signed in to change notification settings - Fork 2
/
query_github_contributions.py
63 lines (43 loc) · 1.25 KB
/
query_github_contributions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
pip install PyGithub
load_secrets
export GIT_RO_TOKEN=$(git_token_for github_ro)
"""
# Authentication is defined via github.Auth
from github import Github
from github import Auth
import os
import ubelt as ub
# using an access token
auth = Auth.Token(os.environ.get('GIT_RO_TOKEN'))
# First create a Github instance:
# Public Web Github
g = Github(auth=auth)
# Github Enterprise with custom hostname
# g = Github(base_url="https://{hostname}/api/v3", auth=auth)
# Then play with your Github objects:
user = g.get_user()
# events = user.get_events()
# e = next(iter(events))
user_repos = []
for repo in user.get_repos():
user_repos.append(repo)
print(repo.name)
username = user.login
open_issues = g.search_issues('', state='open', author=username, type='pr')
closed_issues_iter = g.search_issues('', state='closed', author=username, type='pr')
closed_issues = []
for issue in ub.ProgIter(closed_issues_iter):
print(f'issue={issue}')
print(issue.repository.name)
closed_issues.append(issue)
parent = repo.parent
list(parent.get_pulls())
repo.get_pulls
for repo in user_repos:
if repo.name == 'networkx':
break
...
pulls = repo.get_pulls(state='all', sort='created', base='master')
for pr in pulls:
print(pr.number)