mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Add new create_fork arguments (#2493)
Adds support for new `create_fork` arguments: - `name` - To set the name of the fork on creation - `default_branch_only` - To only include the default branch Signed-off-by: Jonathan Leitschuh <Jonathan.Leitschuh@gmail.com>
This commit is contained in:
+12
-11
@@ -384,23 +384,24 @@ class Organization(github.GithubObject.CompletableGithubObject):
|
||||
"PUT", f"{self.url}/public_members/{public_member._identity}"
|
||||
)
|
||||
|
||||
def create_fork(self, repo):
|
||||
def create_fork(
|
||||
self,
|
||||
repo,
|
||||
name=github.GithubObject.NotSet,
|
||||
default_branch_only=github.GithubObject.NotSet,
|
||||
):
|
||||
"""
|
||||
:calls: `POST /repos/{owner}/{repo}/forks <https://docs.github.com/en/rest/reference/repos#forks>`_
|
||||
:param repo: :class:`github.Repository.Repository`
|
||||
:param name: string
|
||||
:param default_branch_only: bool
|
||||
:rtype: :class:`github.Repository.Repository`
|
||||
"""
|
||||
assert isinstance(repo, github.Repository.Repository), repo
|
||||
url_parameters = {
|
||||
"org": self.login,
|
||||
}
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
f"/repos/{repo.owner.login}/{repo.name}/forks",
|
||||
parameters=url_parameters,
|
||||
)
|
||||
return github.Repository.Repository(
|
||||
self._requester, headers, data, completed=True
|
||||
return repo.create_fork(
|
||||
self,
|
||||
name=name,
|
||||
default_branch_only=default_branch_only,
|
||||
)
|
||||
|
||||
def create_repo_from_template(
|
||||
|
||||
Reference in New Issue
Block a user