Skip to content
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

Add IsTemplate option in create repo ui and api #12942

Merged
merged 2 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions integrations/api_helper_for_declarative_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func doAPICreateRepository(ctx APITestContext, empty bool, callback ...func(*tes
Description: "Temporary repo",
Name: ctx.Reponame,
Private: true,
Template: true,
Gitignores: "",
License: "WTFPL",
Readme: "Default",
Expand Down
1 change: 1 addition & 0 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,7 @@ type CreateRepoOptions struct {
DefaultBranch string
IsPrivate bool
IsMirror bool
IsTemplate bool
AutoInit bool
Status RepositoryStatus
TrustModel TrustModelType
Expand Down
1 change: 1 addition & 0 deletions modules/auth/repo_form.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type CreateRepoForm struct {
IssueLabels string
License string
Readme string
Template bool

RepoTemplate int64
GitContent bool
Expand Down
1 change: 1 addition & 0 deletions modules/repository/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func CreateRepository(doer, u *models.User, opts models.CreateRepoOptions) (*mod
OriginalServiceType: opts.GitServiceType,
IsPrivate: opts.IsPrivate,
IsFsckEnabled: !opts.IsMirror,
IsTemplate: opts.IsTemplate,
CloseIssuesViaCommitInAnyBranch: setting.Repository.DefaultCloseIssuesViaCommitsInAnyBranch,
Status: opts.Status,
IsEmpty: !opts.AutoInit,
Expand Down
2 changes: 2 additions & 0 deletions modules/structs/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ type CreateRepoOption struct {
IssueLabels string `json:"issue_labels"`
// Whether the repository should be auto-intialized?
AutoInit bool `json:"auto_init"`
// Whether the repository is template
Template bool `json:"template"`
// Gitignores to use
Gitignores string `json:"gitignores"`
// License to use
Expand Down
1 change: 1 addition & 0 deletions routers/api/v1/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR
AutoInit: opt.AutoInit,
DefaultBranch: opt.DefaultBranch,
TrustModel: models.ToTrustModel(opt.TrustModel),
IsTemplate: opt.Template,
})
if err != nil {
if models.IsErrRepoAlreadyExist(err) {
Expand Down
1 change: 1 addition & 0 deletions routers/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) {
IsPrivate: form.Private || setting.Repository.ForcePrivate,
DefaultBranch: form.DefaultBranch,
AutoInit: form.AutoInit,
IsTemplate: form.Template,
TrustModel: models.ToTrustModel(form.TrustModel),
})
if err == nil {
Expand Down
7 changes: 7 additions & 0 deletions templates/repo/create.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@
</div>
</div>
</div>
<div class="inline field">
<label>{{.i18n.Tr "repo.template"}}</label>
<div class="ui checkbox">
<input class="hidden" name="template" type="checkbox" tabindex="0">
<label>{{.i18n.Tr "repo.template_helper"}}</label>
</div>
</div>
</div>

<br/>
Expand Down
5 changes: 5 additions & 0 deletions templates/swagger/v1_json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12063,6 +12063,11 @@
"type": "string",
"x-go-name": "Readme"
},
"template": {
"description": "Whether the repository is template",
"type": "boolean",
"x-go-name": "Template"
},
"trust_model": {
"description": "TrustModel of the repository",
"type": "string",
Expand Down