-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add support for creating repos from template repos #1236
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
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
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
|
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.
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.
github/repos.go
Outdated
@@ -334,6 +338,36 @@ func (s *RepositoriesService) Create(ctx context.Context, org string, repo *Repo | |||
return r, resp, nil | |||
} | |||
|
|||
// TemplateRepoRequest represents a request to create a repo from a 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.
For the auto-generated godocs, please end the comment in a period.
github/repos.go
Outdated
Private *bool `json:"private,omitempty"` | ||
} | ||
|
||
// Generate a repository using a repository 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.
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.
github/repos.go
Outdated
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
templateOwner string, templateRepo string,
should be templateOwner, templateRepo string,
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
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 add the required preview header 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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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.
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 |
Thank you, @shanempope, but we prefer that you don't use force-push in this repo, as it makes it more difficult for other contributors to see the change history in case they wish to make comments during the PR review period. Additionally, we always "Squash and merge" in this repo, so it ends up being a single commit anyway, so the force-push is unnecessary. Thank you, @gauntface. Merging. |
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
Issue: #1235