Skip to content

Commit c32280b

Browse files
committed
Start pulls.
1 parent a64e25a commit c32280b

4 files changed

Lines changed: 85 additions & 7 deletions

File tree

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Modules
6666
github
6767
issue
6868
org
69+
pulls
6970
repo
7071

7172
Internals

docs/org.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. module:: github3
2+
.. module:: github3.org
3+
4+
Organization
5+
============
6+
7+
This section of the documentation covers:
8+
9+
- :class:`Organization <Organization>`\ s
10+
- :class:`Team <Team>`\ s
11+
12+
Organization Objects
13+
--------------------
14+
15+
.. autoclass:: Organization
16+
:inherited-members:
17+
18+
------
19+
20+
.. autoclass:: Team
21+
:inherited-members:

docs/pulls.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.. module:: github3
2+
.. module:: github3.pulls
3+
4+
Pull Request
5+
============
6+
7+
This section of the documentation covers:
8+
9+
- :class:`PullRequest <PullRequest>`
10+
- :class:`ReviewComment <ReviewComment>`
11+
- :class:`PullDestination <PullDestination>`
12+
- :class:`PullFile <PullFile>`
13+
14+
Pull Request Objects
15+
--------------------
16+
17+
.. autoclass:: PullRequest
18+
:inherited-members:

github3/pulls.py

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def status(self):
106106

107107

108108
class PullRequest(GitHubCore):
109+
"""The :class:`PullRequest <PullRequest>` object."""
109110
def __init__(self, pull, session):
110111
super(PullRequest, self).__init__(session)
111112
self._update_(pull)
@@ -166,72 +167,98 @@ def _update_(self, pull):
166167

167168
@property
168169
def base(self):
170+
"""Base of the merge"""
169171
return self._base
170172

171173
@property
172174
def body(self):
175+
"""Body of the pull request message"""
173176
return self._body
174177

175178
@property
176179
def closed_at(self):
180+
"""datetime object representing when the pull was closed"""
177181
return self._closed
178182

179183
@property
180184
def created_at(self):
185+
"""datetime object representing when the pull was created"""
181186
return self._created
182187

183188
@property
184189
def diff_url(self):
190+
"""URL to view the diff associated with the pull"""
185191
return self._diff
186192

187193
@property
188194
def head(self):
195+
"""The new head after the pull request"""
189196
return self._head
190197

191198
@property
192199
def html_url(self):
200+
"""The URL of the pull request"""
193201
return self._url
194202

195203
@property
196204
def id(self):
205+
"""The unique id of the pull request"""
197206
return self._id
198207

199208
def is_merged(self):
209+
"""Checks to see if the pull request was merged.
210+
211+
:returns: bool
212+
"""
200213
url = self._api + '/merge'
201214
return self._session.get(url).status_code == 204
202215

203216
@property
204217
def issue_url(self):
218+
"""The URL of the associated issue"""
205219
return self._issue
206220

207221
@property
208222
def links(self):
223+
"""Dictionary of _links"""
209224
return self._links
210225

211226
def list_comments(self):
212-
"""List the comments on this pull request."""
227+
"""List the comments on this pull request.
228+
229+
:returns: list of :class:`ReviewComment <ReviewComment>`\ s
230+
"""
213231
url = self._api + '/comments'
214232
resp = self._get(url)
215233
ses = self._session
216234
return [ReviewComment(comment, ses) for comment in json]
217235

218236
def list_commits(self):
219-
"""List the commits on this pull request."""
237+
"""List the commits on this pull request.
238+
239+
:returns: list of :class:`Commit <github3.git.Commit>`\ s
240+
"""
220241
url = self._api + '/commits'
221242
json = self._get(url)
222243
ses = self._session
223244
return [Commit(commit, ses) for commit in json]
224245

225246
def list_files(self):
226-
"""List the files associated with this pull request."""
247+
"""List the files associated with this pull request.
248+
249+
:returns: list of :class:`PullFile <PullFile>`\ s
250+
"""
227251
url = self._api + '/files'
228252
json = self._get(url)
229253
return [PullFile(f) for f in json]
230254

231255
def merge(self, commit_message=''):
232256
"""Merge this pull request.
233257
234-
:param commit_message: (optional), string
258+
:param commit_message: (optional), message to be used for the merge
259+
commit
260+
:type commit_message: str
261+
:returns: bool
235262
"""
236263
data = {'commit_message': commit_message} if commit_message else None
237264
url = self._api + '/merge'
@@ -242,30 +269,39 @@ def merge(self, commit_message=''):
242269

243270
@property
244271
def merged_at(self):
272+
"""datetime object representing when the pull was merged"""
245273
return self._merged
246274

247275
@property
248276
def number(self):
277+
"""Number of the pull/issue on the repository"""
249278
return self._num
250279

251280
@property
252281
def patch_url(self):
282+
"""The URL of the patch"""
253283
return self._patch_url
254284

255285
@property
256286
def state(self):
287+
"""The state of the pull"""
257288
return self._state
258289

259290
@property
260291
def title(self):
292+
"""The title of the request"""
261293
return self._title
262294

263295
def update(self, title='', body='', state=''):
264296
"""Update this pull request.
265297
266-
:param title: (optional), string
267-
:param body: (optional), string
268-
:param state: (optional), string, ('open', 'closed')
298+
:param title: (optional), title of the pull
299+
:type title: str
300+
:param body: (optional), body of the pull request
301+
:type body: str
302+
:param state: (optional), ('open', 'closed')
303+
:type state: str
304+
:returns: bool
269305
"""
270306
data = dumps({'title': title, 'body': body, 'state': state})
271307
json = self._patch(self._api, data)
@@ -276,6 +312,8 @@ def update(self, title='', body='', state=''):
276312

277313
@property
278314
def user(self):
315+
""":class:`User <github3.user.User>` object representing the creator of
316+
the pull request"""
279317
return self._user
280318

281319

0 commit comments

Comments
 (0)