Add support for creating repos from template repos#1236
Conversation
|
I signed it! |
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
fc591e3 to
04ffdaf
Compare
Codecov Report
@@ Coverage Diff @@
## master #1236 +/- ##
==========================================
+ Coverage 73.36% 73.42% +0.06%
==========================================
Files 86 86
Lines 6026 6040 +14
==========================================
+ Hits 4421 4435 +14
Misses 836 836
Partials 769 769
Continue to review full report at Codecov.
|
04ffdaf to
bb3ceee
Compare
And
|
gmlewis
left a comment
There was a problem hiding this comment.
Thank you, @shanempope. This is a good start, but we need to make some changes.
Meanwhile, I'm going to ask @gauntface what he thinks about the new method name.
| return r, resp, nil | ||
| } | ||
|
|
||
| // TemplateRepoRequest represents a request to create a repo from a template |
There was a problem hiding this comment.
For the auto-generated godocs, please end the comment in a period.
| Private *bool `json:"private,omitempty"` | ||
| } | ||
|
|
||
| // Generate a repository using a repository template |
There was a problem hiding this comment.
Hmmm... I see that GitHub named this endpoint generate, which seems odd to me.
@gauntface - what do you think about calling this endpoint repositories.CreateFromTemplate (or maybe just FromTemplate?) as that seems to more appropriate to me?
Either way, @shanempope, we will want to make this comment a complete sentence for the auto-generated godocs. Hopefully something like:
// CreateFromTemplate generates a repository from a template.
| // Generate a repository using a repository template | ||
| // | ||
| // GitHub API docs: https://developer.github.com/v3/repos/#create-repository-using-a-repository-template | ||
| func (s *RepositoriesService) Generate(ctx context.Context, templateOwner string, templateRepo string, templateRepoReq *TemplateRepoRequest) (*Repository, *Response, error) { |
There was a problem hiding this comment.
templateOwner string, templateRepo string, should be templateOwner, templateRepo string,
| if err != nil { | ||
| return nil, nil, err | ||
| } | ||
|
|
There was a problem hiding this comment.
Please add the required preview header here.
There was a problem hiding this comment.
Thank you!
The docs show the header required throughout the endpoints, in order to get the fields. (Create for example) https://developer.github.com/v3/repos/#create
I will add add it for all the required endpoints.
| v := new(TemplateRepoRequest) | ||
| json.NewDecoder(r.Body).Decode(v) | ||
|
|
||
| testMethod(t, r, "POST") |
There was a problem hiding this comment.
Please test for the required preview header here.
17bce94 to
ed90b7a
Compare
|
Alright, I manually tested all of the endpoints. It's ready for a second review. Thanks @gmlewis |
gmlewis
left a comment
There was a problem hiding this comment.
Thank you, @shanempope!
LGTM.
Let's see what @gauntface thinks about the questions I raised or if he wants to address anything else.
Add support for creating and using template repos preview feature: google#1236 Add API for `POST /repos/:template_owner/:template_repo/generate` endpoint which creates a repository from a template repository. Developer Blog: https://developer.github.com/changes/2019-07-16-repository-templates-api/ API Reference: https://developer.github.com/v3/repos/#create-repository-using-a-repository-template
ed90b7a to
cf71ae0
Compare
|
Thanks @gauntface and @gmlewis. I've squashed the commits |

Add API for
POST /repos/:template_owner/:template_repo/generateendpoint which creates a repository from a template repository.Developer Blog: https://developer.github.com/changes/2019-07-16-repository-templates-api/
API Reference: https://developer.github.com/v3/repos/#create-repository-using-a-repository-template
Issue: #1235