Skip to content

Commit

Permalink
implement Client.create_repository
Browse files Browse the repository at this point in the history
Mutation.createRepository(ownerId:null) field
  • Loading branch information
ShineyDev committed Feb 15, 2025
1 parent 1a1bd93 commit 094e47d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
40 changes: 39 additions & 1 deletion github/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from github.connection import AdvisoryOrder, Connection, SponsorableOrder, VulnerabilityOrder
from github.content import CodeOfConduct, License
from github.organization import Organization
from github.repository import Repository, Topic
from github.repository import Repository, RepositoryVisibility, Topic
from github.security import Advisory, Vulnerability
from github.user import User, UserStatus, Viewer
from github.utility.types import DateTime, T_json_object
Expand Down Expand Up @@ -665,6 +665,44 @@ async def clear_status(

await self._http.mutate_user_update_status(None, None, None, None, None)

async def create_repository(
self,
/,
name: str,
*,
description: str = MISSING,
fields = MISSING, # TODO
visibility: RepositoryVisibility = MISSING,
) -> Repository:
"""
|coro|
Creates a repository on the authenticated user.
Parameters
----------
name: :class:`str`
The name of the repository.
description: :class:`str`
The description of the repository.
visibility: :class:`~github.RepositoryVisibility`
The visibility of the repository.
:rtype: :class:`~github.Repository`
"""

_, repository_data = await self._http.mutate_repositoryowner_create_repository(
None,
description if description is not MISSING else None,
name,
visibility.value if visibility is not MISSING else github.RepositoryVisibility.public.value,
repository_fields=fields,
)

return github.Repository._from_data(repository_data, http=self._http)

async def update_status(
self,
/,
Expand Down
2 changes: 1 addition & 1 deletion github/core/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -2645,7 +2645,7 @@ async def mutate_repository_unarchive(
async def mutate_repositoryowner_create_repository(
self,
/,
repositoryowner_id: str,
repositoryowner_id: str | None,
repository_description: str | None,
repository_name: str,
repository_visibility: str,
Expand Down

0 comments on commit 094e47d

Please sign in to comment.