diff --git a/integrations/api_helper_for_declarative_test.go b/integrations/api_helper_for_declarative_test.go index ec7f1d749..51335c821 100644 --- a/integrations/api_helper_for_declarative_test.go +++ b/integrations/api_helper_for_declarative_test.go @@ -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", diff --git a/models/repo.go b/models/repo.go index 96b359bca..46f91fc7d 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1083,6 +1083,7 @@ type CreateRepoOptions struct { DefaultBranch string IsPrivate bool IsMirror bool + IsTemplate bool AutoInit bool Status RepositoryStatus TrustModel TrustModelType diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index e8809136c..039b0cb58 100644 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -38,6 +38,7 @@ type CreateRepoForm struct { IssueLabels string License string Readme string + Template bool RepoTemplate int64 GitContent bool diff --git a/modules/repository/create.go b/modules/repository/create.go index e6a3e7081..140863781 100644 --- a/modules/repository/create.go +++ b/modules/repository/create.go @@ -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, diff --git a/modules/structs/repo.go b/modules/structs/repo.go index c86b19dfd..a8ca823ef 100644 --- a/modules/structs/repo.go +++ b/modules/structs/repo.go @@ -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 diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index b8a24e253..116e41312 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -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) { diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 12434747e..883d30a5d 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -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 { diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl index 47f540657..d1f847b79 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -181,6 +181,13 @@ +
+ +
+ + +
+

diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index e38344893..51a618ae4 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -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",