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:
Jonathan Leitschuh
2023-05-23 17:40:02 +02:00
committed by GitHub
parent e8075c41dd
commit b94a83cbf3
9 changed files with 62 additions and 26 deletions
+12 -6
View File
@@ -495,18 +495,24 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
self._requester, headers, data, completed=True
)
def create_fork(self, repo):
@staticmethod
def create_fork(
repo,
name=github.GithubObject.NotSet,
default_branch_only=github.GithubObject.NotSet,
):
"""
:calls: `POST /repos/{owner}/{repo}/forks <http://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
headers, data = self._requester.requestJsonAndCheck(
"POST", f"/repos/{repo.owner.login}/{repo.name}/forks"
)
return github.Repository.Repository(
self._requester, headers, data, completed=True
return repo.create_fork(
organization=github.GithubObject.NotSet,
name=name,
default_branch_only=default_branch_only,
)
def create_repo_from_template(