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:
@@ -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(
|
||||
|
||||
@@ -55,7 +55,12 @@ class AuthenticatedUser(CompletableGithubObject):
|
||||
client_secret: Union[str, _NotSetType] = ...,
|
||||
onetime_password: Union[str, None] = ...,
|
||||
) -> Authorization: ...
|
||||
def create_fork(self, repo: Repository) -> Repository: ...
|
||||
@staticmethod
|
||||
def create_fork(
|
||||
repo: Repository,
|
||||
name: Union[str, _NotSetType] = ...,
|
||||
default_branch_only: Union[str, _NotSetType] = ...,
|
||||
) -> Repository: ...
|
||||
def create_gist(
|
||||
self,
|
||||
public: bool,
|
||||
|
||||
+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(
|
||||
|
||||
@@ -35,7 +35,12 @@ class Organization(CompletableGithubObject):
|
||||
@property
|
||||
def company(self) -> Optional[str]: ...
|
||||
def convert_to_outside_collaborator(self, member: NamedUser) -> None: ...
|
||||
def create_fork(self, repo: Repository) -> Repository: ...
|
||||
def create_fork(
|
||||
self,
|
||||
repo: Repository,
|
||||
name: Union[str, _NotSetType] = ...,
|
||||
default_branch_only: Union[str, _NotSetType] = ...,
|
||||
) -> Repository: ...
|
||||
def create_hook(
|
||||
self,
|
||||
name: str,
|
||||
|
||||
+16
-1
@@ -2419,10 +2419,17 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
Repository, self._requester, f"{self.url}/forks", None
|
||||
)
|
||||
|
||||
def create_fork(self, organization=github.GithubObject.NotSet):
|
||||
def create_fork(
|
||||
self,
|
||||
organization=github.GithubObject.NotSet,
|
||||
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 organization: :class:`github.Organization.Organization` or string
|
||||
:param name: string
|
||||
:param default_branch_only: bool
|
||||
:rtype: :class:`github.Repository.Repository`
|
||||
"""
|
||||
post_parameters = {}
|
||||
@@ -2432,6 +2439,14 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
post_parameters["organization"] = organization
|
||||
else:
|
||||
assert organization is github.GithubObject.NotSet, organization
|
||||
assert name is github.GithubObject.NotSet or isinstance(name, str), name
|
||||
assert default_branch_only is github.GithubObject.NotSet or isinstance(
|
||||
default_branch_only, bool
|
||||
), default_branch_only
|
||||
if name is not github.GithubObject.NotSet:
|
||||
post_parameters["name"] = name
|
||||
if default_branch_only is not github.GithubObject.NotSet:
|
||||
post_parameters["default_branch_only"] = default_branch_only
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST",
|
||||
f"{self.url}/forks",
|
||||
|
||||
@@ -365,7 +365,10 @@ class Repository(CompletableGithubObject):
|
||||
def get_events(self) -> PaginatedList[Event]: ...
|
||||
def get_forks(self) -> PaginatedList[Repository]: ...
|
||||
def create_fork(
|
||||
self, organization: Union[Organization, str, _NotSetType] = ...
|
||||
self,
|
||||
organization: Union[Organization, str, _NotSetType] = ...,
|
||||
name: Union[str, _NotSetType] = ...,
|
||||
default_branch_only: Union[str, _NotSetType] = ...,
|
||||
) -> Repository: ...
|
||||
def get_git_blob(self, sha: str) -> GitBlob: ...
|
||||
def get_git_commit(self, sha: str) -> GitCommit: ...
|
||||
|
||||
Reference in New Issue
Block a user