Repository navigation
Expand file tree
/
Copy pathpull_request.py
More file actions
100 lines (76 loc) · 2.89 KB
/
Copy pathpull_request.py
File metadata and controls
100 lines (76 loc) · 2.89 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
from data_types.branch import Branch
from data_types.repository import Repository
from data_types.user import User
class PullRequest:
"""
GitHub Pull Request
https://developer.github.com/v3/pulls/
Attributes:
id: pull request id
html_url: pull request URL
diff_url: pull request URL .diff file
issue_url: issue object (JSON) source
number: PR's number in repository
state: open|closed
title: pull request title
body: pull request message
user: pull request author
sender: pull request sender
merged: whether this request closed or merged
created_at: Opening time
closed_at: Closing time. Null by default
updated_at: Updating time
head: head branch
base: base branch
repository: pull request repository
commits_url: list of commits
review_comments_url: review discussion
requested_reviewers: list of users that has been marked as reviewers
"""
def __init__(self, data):
# Internal GitHub id
self.id = data.get('id', 0)
# Title and Body
self.title = data.get('title', '')
self.body = data.get('body', '')
# Public links
self.html_url = data.get('html_url', '')
self.diff_url = data.get('diff_url', '')
self.issue_url = data.get('issue_url', '')
self.commits_url = data.get('commits_url', '')
self.review_comments_url = data.get('review_comments_url', '')
# open | closed
self.state = data.get('state', '')
# Number in repository
self.number = data.get('number', '')
# Who opened
self.user = None
if 'user' in data:
self.user = User(data['user'])
# Who merged and sends
self.sender = None
if 'sender' in data:
self.sender = User(data['sender'])
# Whether this request closed or merged
self.merged = data.get("merged", False)
# Head branch
self.head = None
if 'head' in data:
self.head = Branch(data['head'])
# Base branch
self.base = None
if 'base' in data:
self.base = Branch(data['base'])
# Repository
self.repository = None
if 'repository' in data:
self.repository = Repository(data['repository'])
# Dates
self.created_at = data.get('created_at', '')
self.closed_at = data.get('closed_at', '')
self.updated_at = data.get('updated_at', '')
# Requested reviewers
self.requested_reviewers = []
if 'requested_reviewers' in data:
for reviewer in data['requested_reviewers']:
self.requested_reviewers.append(User(reviewer))