Add maintainer can modify flag to create pull request (#703)

* Add flag for maintainer can modify when creating pull requests

* Change default to be None to let github decide the behaviour

* Update docstring

* Follow conventions from other functions
This commit is contained in:
Raihaan
2018-02-15 10:07:26 +08:00
committed by Wan Liuyang
parent 98d32af494
commit 0e5a1d1d53
3 changed files with 10 additions and 5 deletions
+8 -3
View File
@@ -1010,19 +1010,24 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param issue: :class:`github.Issue.Issue`
:param base: string
:param head: string
:param maintainer_can_modify: bool
:rtype: :class:`github.PullRequest.PullRequest`
"""
if len(args) + len(kwds) == 4:
if len(args) + len(kwds) >= 4:
return self.__create_pull_1(*args, **kwds)
else:
return self.__create_pull_2(*args, **kwds)
def __create_pull_1(self, title, body, base, head):
def __create_pull_1(self, title, body, base, head, maintainer_can_modify=github.GithubObject.NotSet):
assert isinstance(title, (str, unicode)), title
assert isinstance(body, (str, unicode)), body
assert isinstance(base, (str, unicode)), base
assert isinstance(head, (str, unicode)), head
return self.__create_pull(title=title, body=body, base=base, head=head)
assert maintainer_can_modify is github.GithubObject.NotSet or isinstance(maintainer_can_modify, bool), maintainer_can_modify
if maintainer_can_modify is not github.GithubObject.NotSet:
return self.__create_pull(title=title, body=body, base=base, head=head, maintainer_can_modify=maintainer_can_modify)
else:
return self.__create_pull(title=title, body=body, base=base, head=head)
def __create_pull_2(self, issue, base, head):
assert isinstance(issue, github.Issue.Issue), issue