Skip to content

Commit 9cde776

Browse files
committed
Add WIP method for getting all commits of a user
1 parent e7bc1e3 commit 9cde776

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

datauploader/api/rest.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
GITHUB_RATE_LIMIT_ENDPOINT = "https://api.github.com/rate_limit"
1010
GITHUB_REPOS_ENDPOINT = "https://api.github.com/user/repos?sort=created&per_page=100"
11+
GITHUB_EVENTS_ENDPOINT = "https://api.github.com/users/carolinux/events?sort=created&per_page=100" #FIXME, get username
12+
13+
GITHUB_EVENTS_ENDPOINT="https://api.github.com/repos/anitagraser/TimeManager/commits?author=carolinux&per_page=100"
14+
15+
#https://api.github.com/repos/carolinux/Subs.py/commits?author=carolinux&per_page=100
16+
# also allows for a since param in the url
1117

1218

1319
def get_auth_header(github_access_token):
@@ -45,3 +51,22 @@ def get_user_repos(github_access_token):
4551
url = next['url']
4652
#print("Called the api {} times".format(cnt))
4753
return results
54+
55+
56+
def get_user_events(github_access_token):
57+
results = []
58+
cnt = 0
59+
url = GITHUB_EVENTS_ENDPOINT
60+
while(True):
61+
cnt+=1
62+
response = requests.get(url, headers=get_auth_header(github_access_token))
63+
results += json.loads(response.content)
64+
# if results['type'] == 'PushEvent'
65+
# results[0]['payload']['commits'][0]['message']
66+
next = response.links.get('next')
67+
if not next:
68+
break
69+
else:
70+
url = next['url']
71+
#print("Called the api {} times".format(cnt))
72+
return results

0 commit comments

Comments
 (0)