From 3f77e53725f714fe75c68f383270ba9569c8fd41 Mon Sep 17 00:00:00 2001 From: Thibault Jamet Date: Tue, 16 Jan 2018 22:26:38 +0100 Subject: [PATCH] Add support for changing PR head commit (#632) * Add support for changing PR head commit Signed-off-by: Thibault Jamet * Add support for custom commit arguments Add commit_title, merge_method and sha arguments to the pull request merge method Signed-off-by: Thibault Jamet --- github/PullRequest.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/github/PullRequest.py b/github/PullRequest.py index 7cee6f53..b34e99da 100644 --- a/github/PullRequest.py +++ b/github/PullRequest.py @@ -383,17 +383,19 @@ class PullRequest(github.GithubObject.CompletableGithubObject): ) return github.IssueComment.IssueComment(self._requester, headers, data, completed=True) - def edit(self, title=github.GithubObject.NotSet, body=github.GithubObject.NotSet, state=github.GithubObject.NotSet): + 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 `_ :param title: string :param body: string :param state: string + :param base: string :rtype: None """ assert title is github.GithubObject.NotSet or isinstance(title, (str, unicode)), title assert body is github.GithubObject.NotSet or isinstance(body, (str, unicode)), body assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state + assert base is github.GithubObject.NotSet or isinstance(base, (str, unicode)), base post_parameters = dict() if title is not github.GithubObject.NotSet: post_parameters["title"] = title @@ -401,6 +403,8 @@ class PullRequest(github.GithubObject.CompletableGithubObject): post_parameters["body"] = body if state is not github.GithubObject.NotSet: post_parameters["state"] = state + if base is not github.GithubObject.NotSet: + post_parameters["base"] = base headers, data = self._requester.requestJsonAndCheck( "PATCH", self.url, @@ -548,16 +552,25 @@ class PullRequest(github.GithubObject.CompletableGithubObject): ) return status == 204 - def merge(self, commit_message=github.GithubObject.NotSet): + def merge(self, commit_message=github.GithubObject.NotSet, commit_title=github.GithubObject.NotSet, merge_method=github.GithubObject.NotSet, sha=github.GithubObject.NotSet): """ :calls: `PUT /repos/:owner/:repo/pulls/:number/merge `_ :param commit_message: string :rtype: :class:`github.PullRequestMergeStatus.PullRequestMergeStatus` """ assert commit_message is github.GithubObject.NotSet or isinstance(commit_message, (str, unicode)), commit_message + assert commit_title is github.GithubObject.NotSet or isinstance(commit_title, (str, unicode)), commit_title + assert merge_method is github.GithubObject.NotSet or isinstance(merge_method, (str, unicode)), merge_method + assert sha is github.GithubObject.NotSet or isinstance(sha, (str, unicode)), sha post_parameters = dict() if commit_message is not github.GithubObject.NotSet: post_parameters["commit_message"] = commit_message + if commit_title is not github.GithubObject.NotSet: + post_parameters["commit_title"] = commit_title + if merge_method is not github.GithubObject.NotSet: + post_parameters["merge_method"] = merge_method + if sha is not github.GithubObject.NotSet: + post_parameters["sha"] = sha headers, data = self._requester.requestJsonAndCheck( "PUT", self.url + "/merge",