-
Notifications
You must be signed in to change notification settings - Fork 23
/
get_pr_details.py
61 lines (48 loc) · 1.17 KB
/
get_pr_details.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
from github import Github
from github_token import GITHUB_TOKEN, user, password
g1 = Github(GITHUB_TOKEN)
g2 = Github(user, password)
org = g1.get_organization('coala')
repo = org.get_repo('community')
#Get pull requests for a repo
pulls = repo.get_pulls()
pulls_numbers_list = []
for pull in pulls:
pulls_numbers_list.append(pull.number)
#Get a pull request by its number
pull = repo.get_pull(pulls_numbers_list[0])
#Get pull request details
#see https://developer.github.com/v3/pulls/
#for more options
print (pull.url)
print (pull.issue_url)
print (pull.number)
#For getting details of
#assignee, labels and milestone
#see get_issues_details.py
print (pull.created_at)
print (pull.updated_at)
print (pull.merged_at)
#Get the head details of the pr
head = pull.head
print (head.label)
print (head.sha)
#Get the user for the head
user = head.user
print (user.login)
print (user.url)
#Get the repo of the head
repo = head.repo
print (repo.id)
print (repo.owner)
print (repo.name)
print (repo.url)
#Get the base of the pr
base = pull.base
print (base.label)
print (base.sha)
#Get the user for the base
#Similar to head
#Get the creator of the pr
user = pull.user
print (user.login)