Skip to content

Commit 1195121

Browse files
committed
fix repo create
1 parent f5cd8a9 commit 1195121

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

routers/web/repo/repo.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,28 +131,29 @@ func Create(ctx *context.Context) {
131131
ctx.Data["Title"] = ctx.Tr("new_repo")
132132

133133
// Give default value for template to render.
134-
ctx.Data["Gitignores"] = repo_module.Gitignores
134+
ctx.Data["DefaultGitignores"] = repo_module.Gitignores
135135
ctx.Data["LabelTemplates"] = repo_module.LabelTemplates
136136
ctx.Data["Licenses"] = repo_module.Licenses
137137
ctx.Data["Readmes"] = repo_module.Readmes
138-
ctx.Data["readme"] = "Default"
139-
ctx.Data["private"] = getRepoPrivate(ctx)
138+
ctx.Data["Readme"] = "Default"
139+
ctx.Data["Private"] = getRepoPrivate(ctx)
140140
ctx.Data["IsForcedPrivate"] = setting.Repository.ForcePrivate
141-
ctx.Data["default_branch"] = setting.Repository.DefaultBranch
141+
ctx.Data["DefaultBranch"] = setting.Repository.DefaultBranch
142+
ctx.Data["TrustModel"] = "Default"
142143

143144
ctxUser := checkContextUser(ctx, ctx.FormInt64("org"))
144145
if ctx.Written() {
145146
return
146147
}
147148
ctx.Data["ContextUser"] = ctxUser
148149

149-
ctx.Data["repo_template_name"] = ctx.Tr("repo.template_select")
150+
ctx.Data["RepoTemplateName"] = ctx.Tr("repo.template_select")
150151
templateID := ctx.FormInt64("template_id")
151152
if templateID > 0 {
152153
templateRepo, err := repo_model.GetRepositoryByID(ctx, templateID)
153154
if err == nil && access_model.CheckRepoUnitUser(ctx, templateRepo, ctxUser, unit.TypeCode) {
154-
ctx.Data["repo_template"] = templateID
155-
ctx.Data["repo_template_name"] = templateRepo.Name
155+
ctx.Data["RepoTemplate"] = templateID
156+
ctx.Data["RepoTemplateName"] = templateRepo.Name
156157
}
157158
}
158159

@@ -199,7 +200,7 @@ func CreatePost(ctx *context.Context) {
199200
form := web.GetForm(ctx).(*forms.CreateRepoForm)
200201
ctx.Data["Title"] = ctx.Tr("new_repo")
201202

202-
ctx.Data["Gitignores"] = repo_module.Gitignores
203+
ctx.Data["DefaultGitignores"] = repo_module.Gitignores
203204
ctx.Data["LabelTemplates"] = repo_module.LabelTemplates
204205
ctx.Data["Licenses"] = repo_module.Licenses
205206
ctx.Data["Readmes"] = repo_module.Readmes

templates/repo/create.tmpl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
<div class="inline required field {{if .Err_RepoName}}error{{end}}">
4545
<label for="repo_name">{{.locale.Tr "repo.repo_name"}}</label>
46-
<input id="repo_name" name="repo_name" value="{{.repo_name}}" autofocus required>
46+
<input id="repo_name" name="repo_name" value="{{.RepoName}}" autofocus required>
4747
<span class="help">{{.locale.Tr "repo.repo_name_helper"}}</span>
4848
</div>
4949
<div class="inline field">
@@ -53,21 +53,21 @@
5353
<input name="private" type="checkbox" checked readonly>
5454
<label>{{.locale.Tr "repo.visibility_helper_forced" | Safe}}</label>
5555
{{else}}
56-
<input name="private" type="checkbox" {{if .private}}checked{{end}}>
56+
<input name="private" type="checkbox" {{if .Private}}checked{{end}}>
5757
<label>{{.locale.Tr "repo.visibility_helper" | Safe}}</label>
5858
{{end}}
5959
</div>
6060
<span class="help">{{.locale.Tr "repo.visibility_description"}}</span>
6161
</div>
6262
<div class="inline field {{if .Err_Description}}error{{end}}">
6363
<label for="description">{{.locale.Tr "repo.repo_desc"}}</label>
64-
<textarea id="description" name="description" placeholder="{{.locale.Tr "repo.repo_desc_helper"}}">{{.description}}</textarea>
64+
<textarea id="description" name="description" placeholder="{{.locale.Tr "repo.repo_desc_helper"}}">{{.Description}}</textarea>
6565
</div>
6666
<div class="inline field">
6767
<label>{{.locale.Tr "repo.template"}}</label>
6868
<div id="repo_template_search" class="ui search normal selection dropdown">
69-
<input type="hidden" id="repo_template" name="repo_template" value="{{.repo_template}}">
70-
<div class="default text">{{.repo_template_name}}</div>
69+
<input type="hidden" id="repo_template" name="repo_template" value="{{.RepoTemplate}}">
70+
<div class="default text">{{.RepoTemplateName}}</div>
7171
<div class="menu">
7272
</div>
7373
</div>
@@ -77,33 +77,33 @@
7777
<div class="inline field">
7878
<label>{{.locale.Tr "repo.template.items"}}</label>
7979
<div class="ui checkbox">
80-
<input class="hidden" name="git_content" type="checkbox" tabindex="0" {{if .git_content}}checked{{end}}>
80+
<input class="hidden" name="git_content" type="checkbox" tabindex="0" {{if .GitContent}}checked{{end}}>
8181
<label>{{.locale.Tr "repo.template.git_content"}}</label>
8282
</div>
8383
<div class="ui checkbox{{if not .SignedUser.CanEditGitHook}} tooltip{{end}}"{{if not .SignedUser.CanEditGitHook}} data-content="{{.locale.Tr "repo.template.git_hooks_tooltip"}}"{{end}}>
84-
<input class="hidden" name="git_hooks" type="checkbox" tabindex="0" {{if .git_hooks}}checked{{end}}>
84+
<input class="hidden" name="git_hooks" type="checkbox" tabindex="0" {{if .GitHooks}}checked{{end}}>
8585
<label>{{.locale.Tr "repo.template.git_hooks"}}</label>
8686
</div>
8787
</div>
8888
<div class="inline field">
8989
<label></label>
9090
<div class="ui checkbox">
91-
<input class="hidden" name="webhooks" type="checkbox" tabindex="0" {{if .webhooks}}checked{{end}}>
91+
<input class="hidden" name="webhooks" type="checkbox" tabindex="0" {{if .Webhooks}}checked{{end}}>
9292
<label>{{.locale.Tr "repo.template.webhooks"}}</label>
9393
</div>
9494
<div class="ui checkbox">
95-
<input class="hidden" name="topics" type="checkbox" tabindex="0" {{if .topics}}checked{{end}}>
95+
<input class="hidden" name="topics" type="checkbox" tabindex="0" {{if .Topics}}checked{{end}}>
9696
<label>{{.locale.Tr "repo.template.topics"}}</label>
9797
</div>
9898
</div>
9999
<div class="inline field">
100100
<label></label>
101101
<div class="ui checkbox">
102-
<input class="hidden" name="avatar" type="checkbox" tabindex="0" {{if .avatar}}checked{{end}}>
102+
<input class="hidden" name="avatar" type="checkbox" tabindex="0" {{if .Avatar}}checked{{end}}>
103103
<label>{{.locale.Tr "repo.template.avatar"}}</label>
104104
</div>
105105
<div class="ui checkbox">
106-
<input class="hidden" name="labels" type="checkbox" tabindex="0" {{if .labels}}checked{{end}}>
106+
<input class="hidden" name="labels" type="checkbox" tabindex="0" {{if .Labels}}checked{{end}}>
107107
<label>{{.locale.Tr "repo.template.issue_labels"}}</label>
108108
</div>
109109
</div>
@@ -113,7 +113,7 @@
113113
<div class="inline field">
114114
<label>{{.locale.Tr "repo.issue_labels"}}</label>
115115
<div class="ui search normal selection dropdown">
116-
<input type="hidden" name="issue_labels" value="{{.issueLabels}}">
116+
<input type="hidden" name="issue_labels" value="{{.IssueLabels}}">
117117
<div class="default text">{{.locale.Tr "repo.issue_labels_helper"}}</div>
118118
<div class="menu">
119119
<div class="item" data-value="">{{.locale.Tr "repo.issue_labels_helper"}}</div>
@@ -129,10 +129,10 @@
129129
<div class="inline field">
130130
<label>.gitignore</label>
131131
<div class="ui multiple search normal selection dropdown">
132-
<input type="hidden" name="gitignores" value="{{.gitignores}}">
132+
<input type="hidden" name="gitignores" value="{{.Gitignores}}">
133133
<div class="default text">{{.locale.Tr "repo.repo_gitignore_helper"}}</div>
134134
<div class="menu">
135-
{{range .Gitignores}}
135+
{{range .DefaultGitignores}}
136136
<div class="item" data-value="{{.}}">{{.}}</div>
137137
{{end}}
138138
</div>
@@ -142,7 +142,7 @@
142142
<div class="inline field">
143143
<label>{{.locale.Tr "repo.license"}}</label>
144144
<div class="ui search selection dropdown">
145-
<input type="hidden" name="license" value="{{.license}}">
145+
<input type="hidden" name="license" value="{{.License}}">
146146
<div class="default text">{{.locale.Tr "repo.license_helper"}}</div>
147147
<div class="menu">
148148
<div class="item" data-value="">{{.locale.Tr "repo.license_helper"}}</div>
@@ -157,7 +157,7 @@
157157
<div class="inline field">
158158
<label>{{.locale.Tr "repo.readme"}}</label>
159159
<div class="ui selection dropdown">
160-
<input type="hidden" name="readme" value="{{.readme}}">
160+
<input type="hidden" name="readme" value="{{.Readme}}">
161161
<div class="default text">{{.locale.Tr "repo.readme_helper"}}</div>
162162
<div class="menu">
163163
{{range .Readmes}}
@@ -169,19 +169,19 @@
169169
</div>
170170
<div class="inline field">
171171
<div class="ui checkbox" id="auto-init">
172-
<input class="hidden" name="auto_init" type="checkbox" tabindex="0" {{if .auto_init}}checked{{end}}>
172+
<input class="hidden" name="auto_init" type="checkbox" tabindex="0" {{if .AutoInit}}checked{{end}}>
173173
<label>{{.locale.Tr "repo.auto_init"}}</label>
174174
</div>
175175
</div>
176176
<div class="inline field">
177177
<label for="default_branch">{{.locale.Tr "repo.default_branch"}}</label>
178-
<input id="default_branch" name="default_branch" value="{{.default_branch}}" placeholder="{{.default_branch}}">
178+
<input id="default_branch" name="default_branch" value="{{.DefaultBranch}}" placeholder="{{.DefaultBranch}}">
179179
<span class="help">{{.locale.Tr "repo.default_branch_helper"}}</span>
180180
</div>
181181
<div class="inline field">
182182
<label>{{.locale.Tr "repo.settings.trust_model"}}</label>
183183
<div class="ui selection owner dropdown">
184-
<input type="hidden" id="trust_model" name="trust_model" value="default" required>
184+
<input type="hidden" id="trust_model" name="trust_model" value="{{.TrustModel}}" required>
185185
<div class="default text">{{.locale.Tr "repo.settings.trust_model"}}</div>
186186
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
187187
<div class="menu">
@@ -204,7 +204,7 @@
204204
<div class="inline field">
205205
<label>{{.locale.Tr "repo.template"}}</label>
206206
<div class="ui checkbox">
207-
<input class="hidden" name="template" type="checkbox" tabindex="0">
207+
<input class="hidden" name="template" type="checkbox" tabindex="0" {{if .Template}}checked{{end}}>
208208
<label>{{.locale.Tr "repo.template_helper"}}</label>
209209
</div>
210210
</div>

0 commit comments

Comments
 (0)