Add IsTemplate option in create repo ui and api (#12942)

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
release/v1.15
赵智超 2020-09-25 13:18:37 +08:00 committed by GitHub
parent 7a7f56044a
commit 3c360801b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 20 additions and 0 deletions

View File

@ -48,6 +48,7 @@ func doAPICreateRepository(ctx APITestContext, empty bool, callback ...func(*tes
Description: "Temporary repo", Description: "Temporary repo",
Name: ctx.Reponame, Name: ctx.Reponame,
Private: true, Private: true,
Template: true,
Gitignores: "", Gitignores: "",
License: "WTFPL", License: "WTFPL",
Readme: "Default", Readme: "Default",

View File

@ -1083,6 +1083,7 @@ type CreateRepoOptions struct {
DefaultBranch string DefaultBranch string
IsPrivate bool IsPrivate bool
IsMirror bool IsMirror bool
IsTemplate bool
AutoInit bool AutoInit bool
Status RepositoryStatus Status RepositoryStatus
TrustModel TrustModelType TrustModel TrustModelType

View File

@ -38,6 +38,7 @@ type CreateRepoForm struct {
IssueLabels string IssueLabels string
License string License string
Readme string Readme string
Template bool
RepoTemplate int64 RepoTemplate int64
GitContent bool GitContent bool

View File

@ -40,6 +40,7 @@ func CreateRepository(doer, u *models.User, opts models.CreateRepoOptions) (*mod
OriginalServiceType: opts.GitServiceType, OriginalServiceType: opts.GitServiceType,
IsPrivate: opts.IsPrivate, IsPrivate: opts.IsPrivate,
IsFsckEnabled: !opts.IsMirror, IsFsckEnabled: !opts.IsMirror,
IsTemplate: opts.IsTemplate,
CloseIssuesViaCommitInAnyBranch: setting.Repository.DefaultCloseIssuesViaCommitsInAnyBranch, CloseIssuesViaCommitInAnyBranch: setting.Repository.DefaultCloseIssuesViaCommitsInAnyBranch,
Status: opts.Status, Status: opts.Status,
IsEmpty: !opts.AutoInit, IsEmpty: !opts.AutoInit,

View File

@ -109,6 +109,8 @@ type CreateRepoOption struct {
IssueLabels string `json:"issue_labels"` IssueLabels string `json:"issue_labels"`
// Whether the repository should be auto-intialized? // Whether the repository should be auto-intialized?
AutoInit bool `json:"auto_init"` AutoInit bool `json:"auto_init"`
// Whether the repository is template
Template bool `json:"template"`
// Gitignores to use // Gitignores to use
Gitignores string `json:"gitignores"` Gitignores string `json:"gitignores"`
// License to use // License to use

View File

@ -245,6 +245,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR
AutoInit: opt.AutoInit, AutoInit: opt.AutoInit,
DefaultBranch: opt.DefaultBranch, DefaultBranch: opt.DefaultBranch,
TrustModel: models.ToTrustModel(opt.TrustModel), TrustModel: models.ToTrustModel(opt.TrustModel),
IsTemplate: opt.Template,
}) })
if err != nil { if err != nil {
if models.IsErrRepoAlreadyExist(err) { if models.IsErrRepoAlreadyExist(err) {

View File

@ -250,6 +250,7 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) {
IsPrivate: form.Private || setting.Repository.ForcePrivate, IsPrivate: form.Private || setting.Repository.ForcePrivate,
DefaultBranch: form.DefaultBranch, DefaultBranch: form.DefaultBranch,
AutoInit: form.AutoInit, AutoInit: form.AutoInit,
IsTemplate: form.Template,
TrustModel: models.ToTrustModel(form.TrustModel), TrustModel: models.ToTrustModel(form.TrustModel),
}) })
if err == nil { if err == nil {

View File

@ -181,6 +181,13 @@
</div> </div>
</div> </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> </div>
<br/> <br/>

View File

@ -12063,6 +12063,11 @@
"type": "string", "type": "string",
"x-go-name": "Readme" "x-go-name": "Readme"
}, },
"template": {
"description": "Whether the repository is template",
"type": "boolean",
"x-go-name": "Template"
},
"trust_model": { "trust_model": {
"description": "TrustModel of the repository", "description": "TrustModel of the repository",
"type": "string", "type": "string",