-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Adds support to create repository from a template #1395
Changes from all commits
3f54ace
deea076
a91899b
ed363bb
ec44a8b
1aac6e9
1e4e605
a29b3c4
b4f5991
d1c282e
30e7100
2c384f3
0bfe56d
a95e448
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 |
---|---|---|
|
@@ -405,6 +405,47 @@ 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, | ||
): | ||
"""self.name | ||
: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, | ||
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. I wonder if we should use self._identity here. 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. neither |
||
} | ||
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_hook( | ||
self, | ||
name, | ||
|
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
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.
Perhaps we should abstract this out to a mix-in, since it's identical...