+
Skip to content

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

Merged
merged 1 commit into from
Jul 25, 2019

Conversation

shanempope
Copy link
Contributor

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

@googlebot
Copy link

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. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@shanempope
Copy link
Contributor Author

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes Indication that the PR author has signed a Google Contributor License Agreement. and removed cla: no labels Jul 23, 2019
@shanempope shanempope force-pushed the repo-template-support branch from fc591e3 to 04ffdaf Compare July 23, 2019 05:08
@codecov
Copy link

codecov bot commented Jul 23, 2019

Codecov Report

Merging #1236 into master will increase coverage by 0.06%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
github/github.go 89.31% <ø> (ø) ⬆️
github/repos.go 75.16% <100%> (+0.79%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c756c32...cf71ae0. Read the comment docs.

@shanempope shanempope force-pushed the repo-template-support branch from 04ffdaf to bb3ceee Compare July 23, 2019 05:19
@shanempope
Copy link
Contributor Author

Note: Creating and using repository templates is currently available for developers to preview. To access this new endpoint during the preview period, you must provide a custom media type in the Accept header:

application/vnd.github.baptiste-preview+json

And

Warning: The API may change without advance notice during the preview period. Preview features are not supported for production use. If you experience any issues, contact GitHub Support.

Copy link
Collaborator

@gmlewis gmlewis left a 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
Copy link
Collaborator

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
Copy link
Collaborator

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) {
Copy link
Collaborator

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
}

Copy link
Collaborator

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.

Copy link
Contributor Author

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")
Copy link
Collaborator

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.

@gmlewis gmlewis requested a review from gauntface July 23, 2019 13:07
@shanempope shanempope force-pushed the repo-template-support branch from 17bce94 to ed90b7a Compare July 23, 2019 18:51
@shanempope
Copy link
Contributor Author

Alright, I manually tested all of the endpoints. It's ready for a second review. Thanks @gmlewis

Copy link
Collaborator

@gmlewis gmlewis left a 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
@shanempope shanempope force-pushed the repo-template-support branch from ed90b7a to cf71ae0 Compare July 25, 2019 02:44
@shanempope
Copy link
Contributor Author

Thanks @gauntface and @gmlewis. I've squashed the commits

@gmlewis
Copy link
Collaborator

gmlewis commented Jul 25, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Indication that the PR author has signed a Google Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载