Skip to content

Commit

Permalink
♻ Make changes so it's closer to main branch
Browse files Browse the repository at this point in the history
♻Rewrite to make things conform closer to main branch

♻ Fix f string

♻ Change to f string

And also switch to the accept header recommended in https://docs.github.com/en/rest/reference/repos#create-a-repository-using-a-template

♻ Move away from `application/vnd.github.baptiste-preview+json`

✅Make tests pass

✅Fix tests

🎨 FIX: the formatting by running `tox -elint`
  • Loading branch information
simkimsia committed Dec 1, 2021
1 parent a116c16 commit 8531073
Show file tree
Hide file tree
Showing 9 changed files with 602 additions and 147 deletions.
12 changes: 8 additions & 4 deletions github/AuthenticatedUser.py
Expand Up @@ -517,7 +517,7 @@ def create_repo_from_template(
private=github.GithubObject.NotSet,
):
"""
:calls: `POST /repos/{template_owner}/{template_repo}/generate <http://docs.github.com/en/rest/reference/repos#create-a-repository-using-a-template>`_
:calls: `POST /repos/{template_owner}/{template_repo}/generate <https://docs.github.com/en/rest/reference/repos#create-a-repository-using-a-template>`_
:param name: string
:param repo :class:`github.Repository.Repository`
:param description: string
Expand All @@ -529,7 +529,9 @@ def create_repo_from_template(
assert description is github.GithubObject.NotSet or isinstance(
description, str
), description
assert private is github.GithubObject.NotSet or isinstance(private, bool), private
assert private is github.GithubObject.NotSet or isinstance(
private, bool
), private
post_parameters = {
"name": name,
"owner": self.login,
Expand All @@ -542,9 +544,11 @@ def create_repo_from_template(
"POST",
f"/repos/{repo.owner.login}/{repo.name}/generate",
input=post_parameters,
headers={"Accept": Consts.mediaTypeTemplatesPreview},
headers={"Accept": "application/vnd.github.v3+json"},
)
return github.Repository.Repository(
self._requester, headers, data, completed=True
)
return github.Repository.Repository(self._requester, headers, data, completed=True)

def create_gist(self, public, files, description=github.GithubObject.NotSet):
"""
Expand Down
6 changes: 3 additions & 3 deletions github/Organization.py
Expand Up @@ -411,7 +411,7 @@ def create_repo_from_template(
private=github.GithubObject.NotSet,
):
"""self.name
:calls: `POST /repos/{template_owner}/{template_repo}/generate <http://docs.github.com/en/rest/reference/repos#create-a-repository-using-a-template>`_
:calls: `POST /repos/{template_owner}/{template_repo}/generate <https://docs.github.com/en/rest/reference/repos#create-a-repository-using-a-template>`_
:param name: string
:param repo :class:`github.Repository.Repository`
:param description: string
Expand All @@ -436,9 +436,9 @@ def create_repo_from_template(
post_parameters["private"] = private
headers, data = self._requester.requestJsonAndCheck(
"POST",
"/repos/" + repo.owner.login + "/" + repo.name + "/generate",
f"/repos/{repo.owner.login}/{repo.name}/generate",
input=post_parameters,
headers={"Accept": Consts.mediaTypeTemplatesPreview},
headers={"Accept": "application/vnd.github.v3+json"},
)
return github.Repository.Repository(
self._requester, headers, data, completed=True
Expand Down

0 comments on commit 8531073

Please sign in to comment.