mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Added option to create review for Pull request (#662)
* Added option to create review for Pull request * Fix tests
This commit is contained in:
committed by
Wan Liuyang
parent
3cd176e3c3
commit
162f0397bc
@@ -392,6 +392,31 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
|
||||
)
|
||||
return github.IssueComment.IssueComment(self._requester, headers, data, completed=True)
|
||||
|
||||
def create_review(self, commit, body, event=github.GithubObject.NotSet, comments=github.GithubObject.NotSet):
|
||||
"""
|
||||
:calls: `POST /repos/:owner/:repo/pulls/:number/reviews <https://developer.github.com/v3/pulls/reviews/>`_
|
||||
:param commit: github.Commit.Commit
|
||||
:param body: string
|
||||
:param event: string
|
||||
:param comments: list
|
||||
:rtype: :class:`github.PullRequestReview.PullRequestReview`
|
||||
"""
|
||||
assert isinstance(commit, github.Commit.Commit), commit
|
||||
assert isinstance(body, str), body
|
||||
assert event is github.GithubObject.NotSet or isinstance(event, str), event
|
||||
assert comments is github.GithubObject.NotSet or isinstance(comments, list), comments
|
||||
post_parameters = {'commit_id': commit.sha, 'body': body}
|
||||
post_parameters['event'] = 'COMMENT' if event == github.GithubObject.NotSet else event
|
||||
if comments is github.GithubObject.NotSet:
|
||||
post_parameters['comments'] = []
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
self.url + "/reviews",
|
||||
input=post_parameters
|
||||
)
|
||||
self._useAttributes(data)
|
||||
return github.PullRequestReview.PullRequestReview(self._requester, headers, data, completed=True)
|
||||
|
||||
def edit(self, title=github.GithubObject.NotSet, body=github.GithubObject.NotSet, state=github.GithubObject.NotSet, base=github.GithubObject.NotSet):
|
||||
"""
|
||||
:calls: `PATCH /repos/:owner/:repo/pulls/:number <http://developer.github.com/v3/pulls>`_
|
||||
|
||||
Reference in New Issue
Block a user