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
Adds support to create repository from a template #1395
Conversation
), private | ||
post_parameters = { | ||
"name": name, | ||
"owner": self.login, |
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.
I wonder if we should use self._identity here.
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.
neither Organization
nor AuthenticatedUser
have an _identity
property
@@ -357,6 +357,47 @@ def create_fork(self, repo): | |||
self._requester, headers, data, completed=True | |||
) | |||
|
|||
def create_repo_from_template( |
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...
I love the direction, but I think we need to have a think about how we implement this before we land it. |
Codecov Report
@@ Coverage Diff @@
## master #1395 +/- ##
==========================================
+ Coverage 98.20% 98.35% +0.14%
==========================================
Files 188 188
Lines 14071 14140 +69
==========================================
+ Hits 13819 13907 +88
+ Misses 252 233 -19
Continue to review full report at Codecov.
|
@s-t-e-v-e-n-k thanks for the review! The We could even keep the Org and AuthUser methods which would call the Repo method and set the appropriate owner. Thoughts? |
Codecov Report
@@ Coverage Diff @@
## master #1395 +/- ##
=======================================
Coverage 98.35% 98.35%
=======================================
Files 188 188
Lines 14140 14140
=======================================
Hits 13907 13907
Misses 233 233 Continue to review full report at Codecov.
|
@s-t-e-v-e-n-k thoughts on my comment above? |
@isouza-daitan Sorry for the late reply. From a correctness perspective Repository is probably the right place, but given our architecture it's hard to require a user grab a repository object just to create a different repo, potentially in a different namespace entirely. I'm still against the code duplication -- how about one method on AuthenicatedUser that also takes owner as NotSet. If owner is NotSet, use self.login, otherwise assert it's an Organization (or an id). What do you think? |
@s-t-e-v-e-n-k won't we have auth problems if we try to create a new repo in an org using an AuthenticatedUser instance? I agree getting a Repository to create a new repo is not great.
and we call |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Codecov Report
@@ Coverage Diff @@
## master #1395 +/- ##
=======================================
Coverage 98.67% 98.67%
=======================================
Files 48 48
Lines 2561 2562 +1
=======================================
+ Hits 2527 2528 +1
Misses 34 34
Continue to review full report at Codecov.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
…hub into create-from-template
@sfdye done, sorry for the delay. |
Its also worth adding that the |
I kinda need this. Can solve the conflict? @isouza-daitan |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Please reopen and consider merging #2090 |
This PR adds a new
create_repo_from_template
method toAuthenticatedUser
andOrganization
that uses the new/generate
endpoint of a repo. I followed the same pattern as the similarcreate_fork
method;I also added a new
is_template
attribute to theRepository
class. This attribute will only be sent by Github when we use the feature'sAccept
header which I only added to the POST to create the new repo. Let me know if I should also add it toget_repo
calls.The documentation mentions a template_repository attribute but Github never sends it.