8000 Add sha parameter to Pull Request merge · drobertduke/github3.py@effa411 · GitHub
[go: up one dir, main page]

Skip to content

Commit effa411

Browse files
author
David Duke
committed
Add sha parameter to Pull Request merge
The Github v3 API supports an optional 'sha' parameter to explicitly specify the commit that should be at the head of a Pull Request when merging it. https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button
1 parent 48adfa8 commit effa411

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

github3/pulls.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,16 +286,18 @@ def issue_comments(self, number=-1, etag=None):
286286
return self._iter(int(number), url, IssueComment, etag=etag)
287287

288288
@requires_auth
289-
def merge(self, commit_message=''):
289+
def merge(self, commit_message='', sha=None):
290290
"""Merge this pull request.
291291
292292
:param str commit_message: (optional), message to be used for the
293293
merge commit
294294
:returns: bool
295295
"""
296-
data = dumps({'commit_message': commit_message})
296+
parameters = {'commit_message': commit_message}
297+
if sha:
298+
parameters['sha'] = sha
297299
url = self._build_url('merge', base_url=self._api)
298-
json = self._json(self._put(url, data=data), 200)
300+
json = self._json(self._put(url, data=dumps(parameters)), 200)
299301
if not json:
300302
return False
301303
return json['merged']

0 commit comments

Comments
 (0)
0