[Feature] Create repositories from a template repo - #1590
Merged
Conversation
colinshum
marked this pull request as ready for review
August 27, 2020 21:58
Contributor
Author
vilmibm
suggested changes
Aug 27, 2020
| Visibility: visibility, | ||
| OwnerID: repoToCreate.RepoOwner(), | ||
| TeamID: opts.Team, | ||
| RepositoryID: opts.Template, |
Contributor
There was a problem hiding this comment.
Since this type is intended to pass as input for the create repo mutation I'm not in love with using it to signal the desire to clone from a template.
I'd rather see:
- a new helper,
repoCreateFromTemplate - a change to
repoCreate's function signature to accept a potentially empty template argument
Contributor
Author
There was a problem hiding this comment.
Addressed in f465b07
@vilmibm I've refactored the changes so that repoCreate is a variadic function:
func repoCreate(client *http.Client, hostname string, input repoCreateInput, template ...string) (*api.Repository, error)
As a result, I was able to remove RepositoryID from the repoCreateInput block, and passed it as an argument instead whenever repoCreate was called 😄
This comment was marked as spam.
This comment was marked as spam.
colinshum
force-pushed
the
colinshum/template-repo
branch
2 times, most recently
from
August 27, 2020 23:15
957c31f to
f465b07
Compare
Contributor
Author
vilmibm
suggested changes
Aug 28, 2020
vilmibm
left a comment
Contributor
There was a problem hiding this comment.
one last tiny nitpick then we're good!
colinshum
force-pushed
the
colinshum/template-repo
branch
from
August 28, 2020 18:58
10d25fc to
34c3718
Compare
colinshum
force-pushed
the
colinshum/template-repo
branch
from
August 28, 2020 19:02
34c3718 to
99372f0
Compare
vilmibm
approved these changes
Aug 28, 2020
12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1578
In this PR, I added functionality to use the following command to create a new repo from a template:
gh repo create <new-repo-name> --template="<link-to-template-repo> OR <owner/template-repo>"Changes
I used the
cloneTemplateRepositorymutation from the public GraphQL API to achieve this functionality. You can read more about it here: GraphQL DocsA limitation of using this mutation is that it does not fully support all of the inputs that the
createRepositorymutation does. Therefore, I had to add some ad-hoc input processing to warn the user about passing incompatible flags with--template.This seemed to be the most straightforward approach, as we do not want to modify the
createRepositorymutation to support this existing functionality.Example
Note:
--enable-wiki="true"or--enable-issues="true"will not throw an error, as those are repo defaults. However, if you passfalse, it will raise thisFlagError.Demo
Checklist