Skip to content

Commit 3c36080

Browse files
a1012112796lafriks
andauthored
Add IsTemplate option in create repo ui and api (#12942)
Signed-off-by: a1012112796 <[email protected]> Co-authored-by: Lauris BH <[email protected]>
1 parent 7a7f560 commit 3c36080

File tree

9 files changed

+20
-0
lines changed

9 files changed

+20
-0
lines changed

integrations/api_helper_for_declarative_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func doAPICreateRepository(ctx APITestContext, empty bool, callback ...func(*tes
4848
Description: "Temporary repo",
4949
Name: ctx.Reponame,
5050
Private: true,
51+
Template: true,
5152
Gitignores: "",
5253
License: "WTFPL",
5354
Readme: "Default",

models/repo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,7 @@ type CreateRepoOptions struct {
10831083
DefaultBranch string
10841084
IsPrivate bool
10851085
IsMirror bool
1086+
IsTemplate bool
10861087
AutoInit bool
10871088
Status RepositoryStatus
10881089
TrustModel TrustModelType

modules/auth/repo_form.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type CreateRepoForm struct {
3838
IssueLabels string
3939
License string
4040
Readme string
41+
Template bool
4142

4243
RepoTemplate int64
4344
GitContent bool

modules/repository/create.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func CreateRepository(doer, u *models.User, opts models.CreateRepoOptions) (*mod
4040
OriginalServiceType: opts.GitServiceType,
4141
IsPrivate: opts.IsPrivate,
4242
IsFsckEnabled: !opts.IsMirror,
43+
IsTemplate: opts.IsTemplate,
4344
CloseIssuesViaCommitInAnyBranch: setting.Repository.DefaultCloseIssuesViaCommitsInAnyBranch,
4445
Status: opts.Status,
4546
IsEmpty: !opts.AutoInit,

modules/structs/repo.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ type CreateRepoOption struct {
109109
IssueLabels string `json:"issue_labels"`
110110
// Whether the repository should be auto-intialized?
111111
AutoInit bool `json:"auto_init"`
112+
// Whether the repository is template
113+
Template bool `json:"template"`
112114
// Gitignores to use
113115
Gitignores string `json:"gitignores"`
114116
// License to use

routers/api/v1/repo/repo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR
245245
AutoInit: opt.AutoInit,
246246
DefaultBranch: opt.DefaultBranch,
247247
TrustModel: models.ToTrustModel(opt.TrustModel),
248+
IsTemplate: opt.Template,
248249
})
249250
if err != nil {
250251
if models.IsErrRepoAlreadyExist(err) {

routers/repo/repo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) {
250250
IsPrivate: form.Private || setting.Repository.ForcePrivate,
251251
DefaultBranch: form.DefaultBranch,
252252
AutoInit: form.AutoInit,
253+
IsTemplate: form.Template,
253254
TrustModel: models.ToTrustModel(form.TrustModel),
254255
})
255256
if err == nil {

templates/repo/create.tmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@
181181
</div>
182182
</div>
183183
</div>
184+
<div class="inline field">
185+
<label>{{.i18n.Tr "repo.template"}}</label>
186+
<div class="ui checkbox">
187+
<input class="hidden" name="template" type="checkbox" tabindex="0">
188+
<label>{{.i18n.Tr "repo.template_helper"}}</label>
189+
</div>
190+
</div>
184191
</div>
185192

186193
<br/>

templates/swagger/v1_json.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12063,6 +12063,11 @@
1206312063
"type": "string",
1206412064
"x-go-name": "Readme"
1206512065
},
12066+
"template": {
12067+
"description": "Whether the repository is template",
12068+
"type": "boolean",
12069+
"x-go-name": "Template"
12070+
},
1206612071
"trust_model": {
1206712072
"description": "TrustModel of the repository",
1206812073
"type": "string",

0 commit comments

Comments
 (0)