New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create from template #2012
Create from template #2012
Changes from 25 commits
3f54ace
deea076
a91899b
ed363bb
ec44a8b
1aac6e9
1e4e605
a29b3c4
b4f5991
d1c282e
30e7100
2c384f3
0bfe56d
a95e448
8fa9341
18c1d07
476ee42
b018853
aca2570
3b53479
ba76eff
f0372a9
efb9dc2
d8c105c
e35e31d
6ddabf7
652bdcc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -501,6 +501,88 @@ def create_fork(self, repo): | |
self._requester, headers, data, completed=True | ||
) | ||
|
||
def create_repo_from_template( | ||
self, | ||
name, | ||
repo, | ||
description=github.GithubObject.NotSet, | ||
private=github.GithubObject.NotSet, | ||
): | ||
""" | ||
:calls: `POST /repos/:template_owner/:template_repo/generate <https://developer.github.com/v3/repos/#create-repository-using-a-repository-template>` | ||
:param name: string | ||
:param repo :class:`github.Repository.Repository` | ||
:param description: string | ||
:param private: bool | ||
:rtype: :class:`github.Repository.Repository` | ||
""" | ||
assert isinstance(name, str), name | ||
assert isinstance(repo, github.Repository.Repository), repo | ||
assert description is github.GithubObject.NotSet or isinstance( | ||
description, str | ||
), description | ||
assert private is github.GithubObject.NotSet or isinstance( | ||
private, bool | ||
), private | ||
post_parameters = { | ||
"name": name, | ||
"owner": self.login, | ||
} | ||
if description is not github.GithubObject.NotSet: | ||
post_parameters["description"] = description | ||
if private is not github.GithubObject.NotSet: | ||
post_parameters["private"] = private | ||
headers, data = self._requester.requestJsonAndCheck( | ||
"POST", | ||
"/repos/" + repo.owner.login + "/" + repo.name + "/generate", | ||
input=post_parameters, | ||
headers={"Accept": Consts.mediaTypeTemplatesPreview}, | ||
) | ||
return github.Repository.Repository( | ||
self._requester, headers, data, completed=True | ||
) | ||
|
||
def create_repo_from_template( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is duplicated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed in 6ddabf7 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
NOt too sure what this means. Can advise after my commit 6ddabf7 |
||
self, | ||
name, | ||
repo, | ||
description=github.GithubObject.NotSet, | ||
private=github.GithubObject.NotSet, | ||
): | ||
""" | ||
:calls: `POST /repos/:template_owner/:template_repo/generate <https://developer.github.com/v3/repos/#create-repository-using-a-repository-template>` | ||
:param name: string | ||
:param repo :class:`github.Repository.Repository` | ||
:param description: string | ||
:param private: bool | ||
:rtype: :class:`github.Repository.Repository` | ||
""" | ||
assert isinstance(name, str), name | ||
assert isinstance(repo, github.Repository.Repository), repo | ||
assert description is github.GithubObject.NotSet or isinstance( | ||
description, str | ||
), description | ||
assert private is github.GithubObject.NotSet or isinstance( | ||
private, bool | ||
), private | ||
post_parameters = { | ||
"name": name, | ||
"owner": self.login, | ||
} | ||
if description is not github.GithubObject.NotSet: | ||
post_parameters["description"] = description | ||
if private is not github.GithubObject.NotSet: | ||
post_parameters["private"] = private | ||
headers, data = self._requester.requestJsonAndCheck( | ||
"POST", | ||
"/repos/" + repo.owner.login + "/" + repo.name + "/generate", | ||
input=post_parameters, | ||
headers={"Accept": Consts.mediaTypeTemplatesPreview}, | ||
) | ||
return github.Repository.Repository( | ||
self._requester, headers, data, completed=True | ||
) | ||
|
||
def create_gist(self, public, files, description=github.GithubObject.NotSet): | ||
""" | ||
:calls: `POST /gists <http://docs.github.com/en/rest/reference/gists>`_ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use an f-string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be resolved by 6ddabf7