Skip to content

Commit f4629fc

Browse files
authored
Move repo.CloseIssuesViaCommitInAnyBranch to issue settings (#14965)
1 parent ad42ada commit f4629fc

File tree

3 files changed

+44
-36
lines changed

3 files changed

+44
-36
lines changed

modules/forms/repo_form.go

+23-23
Original file line numberDiff line numberDiff line change
@@ -123,34 +123,34 @@ type RepoSettingForm struct {
123123
EnablePrune bool
124124

125125
// Advanced settings
126-
EnableWiki bool
127-
EnableExternalWiki bool
128-
ExternalWikiURL string
129-
EnableIssues bool
130-
EnableExternalTracker bool
131-
ExternalTrackerURL string
132-
TrackerURLFormat string
133-
TrackerIssueStyle string
134-
EnableProjects bool
135-
EnablePulls bool
136-
PullsIgnoreWhitespace bool
137-
PullsAllowMerge bool
138-
PullsAllowRebase bool
139-
PullsAllowRebaseMerge bool
140-
PullsAllowSquash bool
141-
PullsAllowManualMerge bool
142-
EnableAutodetectManualMerge bool
143-
EnableTimetracker bool
144-
AllowOnlyContributorsToTrackTime bool
145-
EnableIssueDependencies bool
146-
IsArchived bool
126+
EnableWiki bool
127+
EnableExternalWiki bool
128+
ExternalWikiURL string
129+
EnableIssues bool
130+
EnableExternalTracker bool
131+
ExternalTrackerURL string
132+
TrackerURLFormat string
133+
TrackerIssueStyle string
134+
EnableCloseIssuesViaCommitInAnyBranch bool
135+
EnableProjects bool
136+
EnablePulls bool
137+
PullsIgnoreWhitespace bool
138+
PullsAllowMerge bool
139+
PullsAllowRebase bool
140+
PullsAllowRebaseMerge bool
141+
PullsAllowSquash bool
142+
PullsAllowManualMerge bool
143+
EnableAutodetectManualMerge bool
144+
EnableTimetracker bool
145+
AllowOnlyContributorsToTrackTime bool
146+
EnableIssueDependencies bool
147+
IsArchived bool
147148

148149
// Signing Settings
149150
TrustModel string
150151

151152
// Admin settings
152-
EnableHealthCheck bool
153-
EnableCloseIssuesViaCommitInAnyBranch bool
153+
EnableHealthCheck bool
154154
}
155155

156156
// Validate validates the fields

routers/repo/setting.go

+12-4
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,19 @@ func SettingsPost(ctx *context.Context) {
216216
ctx.Redirect(repo.Link() + "/settings")
217217

218218
case "advanced":
219+
var repoChanged bool
219220
var units []models.RepoUnit
220221
var deleteUnitTypes []models.UnitType
221222

222223
// This section doesn't require repo_name/RepoName to be set in the form, don't show it
223224
// as an error on the UI for this action
224225
ctx.Data["Err_RepoName"] = nil
225226

227+
if repo.CloseIssuesViaCommitInAnyBranch != form.EnableCloseIssuesViaCommitInAnyBranch {
228+
repo.CloseIssuesViaCommitInAnyBranch = form.EnableCloseIssuesViaCommitInAnyBranch
229+
repoChanged = true
230+
}
231+
226232
if form.EnableWiki && form.EnableExternalWiki && !models.UnitTypeExternalWiki.UnitGlobalDisabled() {
227233
if !validation.IsValidExternalURL(form.ExternalWikiURL) {
228234
ctx.Flash.Error(ctx.Tr("repo.settings.external_wiki_url_error"))
@@ -326,6 +332,12 @@ func SettingsPost(ctx *context.Context) {
326332
ctx.ServerError("UpdateRepositoryUnits", err)
327333
return
328334
}
335+
if repoChanged {
336+
if err := models.UpdateRepository(repo, false); err != nil {
337+
ctx.ServerError("UpdateRepository", err)
338+
return
339+
}
340+
}
329341
log.Trace("Repository advanced settings updated: %s/%s", ctx.Repo.Owner.Name, repo.Name)
330342

331343
ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success"))
@@ -361,10 +373,6 @@ func SettingsPost(ctx *context.Context) {
361373
repo.IsFsckEnabled = form.EnableHealthCheck
362374
}
363375

364-
if repo.CloseIssuesViaCommitInAnyBranch != form.EnableCloseIssuesViaCommitInAnyBranch {
365-
repo.CloseIssuesViaCommitInAnyBranch = form.EnableCloseIssuesViaCommitInAnyBranch
366-
}
367-
368376
if err := models.UpdateRepository(repo, false); err != nil {
369377
ctx.ServerError("UpdateRepository", err)
370378
return

templates/repo/settings/options.tmpl

+9-9
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,16 @@
221221
</div>
222222
</div>
223223
{{end}}
224-
<div class="field">
225-
<div class="ui checkbox">
226-
<input name="enable_issue_dependencies" type="checkbox" {{if (.Repository.IsDependenciesEnabled)}}checked{{end}}>
227-
<label>{{.i18n.Tr "repo.issues.dependency.setting"}}</label>
228-
</div>
224+
<div class="field">
225+
<div class="ui checkbox">
226+
<input name="enable_issue_dependencies" type="checkbox" {{if (.Repository.IsDependenciesEnabled)}}checked{{end}}>
227+
<label>{{.i18n.Tr "repo.issues.dependency.setting"}}</label>
229228
</div>
229+
</div>
230+
<div class="ui checkbox">
231+
<input name="enable_close_issues_via_commit_in_any_branch" type="checkbox" {{ if .Repository.CloseIssuesViaCommitInAnyBranch }}checked{{end}}>
232+
<label>{{.i18n.Tr "repo.settings.admin_enable_close_issues_via_commit_in_any_branch"}}</label>
233+
</div>
230234
</div>
231235
<div class="field">
232236
{{if .UnitTypeExternalTracker.UnitGlobalDisabled}}
@@ -412,10 +416,6 @@
412416
<label>{{.i18n.Tr "repo.settings.admin_enable_health_check"}}</label>
413417
</div>
414418
</div>
415-
<div class="ui checkbox">
416-
<input name="enable_close_issues_via_commit_in_any_branch" type="checkbox" {{ if .Repository.CloseIssuesViaCommitInAnyBranch }}checked{{end}}>
417-
<label>{{.i18n.Tr "repo.settings.admin_enable_close_issues_via_commit_in_any_branch"}}</label>
418-
</div>
419419

420420
<div class="ui divider"></div>
421421
<div class="field">

0 commit comments

Comments
 (0)