From 118def30a3ee69e203113cc64dceea27ece12e13 Mon Sep 17 00:00:00 2001 From: MurphyZhao Date: Wed, 13 Mar 2019 10:47:38 +0800 Subject: [PATCH] [fix] the default vaule of 'PullRequest.create_review'`s commit param (#1058) [fix] the default vaule of github.PullRequest.PullRequest.create_review`s input param commit. In `POST /repos/:owner/:repo/pulls/:number/reviews`, 'commit_id' is not a necessary parameter.Reference [https://developer.github.com/v3/pulls/reviews/](https://developer.github.com/v3/pulls/reviews/) Signed-off-by: MurphyZhao --- github/PullRequest.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/github/PullRequest.py b/github/PullRequest.py index 2dc354f8..af2100fe 100644 --- a/github/PullRequest.py +++ b/github/PullRequest.py @@ -418,7 +418,7 @@ 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): + def create_review(self, commit=github.GithubObject.NotSet, body=None, event=github.GithubObject.NotSet, comments=github.GithubObject.NotSet): """ :calls: `POST /repos/:owner/:repo/pulls/:number/reviews `_ :param commit: github.Commit.Commit @@ -427,11 +427,14 @@ class PullRequest(github.GithubObject.CompletableGithubObject): :param comments: list :rtype: :class:`github.PullRequestReview.PullRequestReview` """ - assert isinstance(commit, github.Commit.Commit), commit + assert commit is github.GithubObject.NotSet or 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 = dict() + if commit is not github.GithubObject.NotSet: + post_parameters['commit_id'] = commit.sha + post_parameters['body'] = body post_parameters['event'] = 'COMMENT' if event == github.GithubObject.NotSet else event if comments is github.GithubObject.NotSet: post_parameters['comments'] = []