Move repo.CloseIssuesViaCommitInAnyBranch to issue settings (#14965)

This commit is contained in:
Norwin 2021-03-16 01:00:52 +00:00 committed by GitHub
parent ad42adac93
commit f4629fc472
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 36 deletions

View file

@ -123,34 +123,34 @@ type RepoSettingForm struct {
EnablePrune bool EnablePrune bool
// Advanced settings // Advanced settings
EnableWiki bool EnableWiki bool
EnableExternalWiki bool EnableExternalWiki bool
ExternalWikiURL string ExternalWikiURL string
EnableIssues bool EnableIssues bool
EnableExternalTracker bool EnableExternalTracker bool
ExternalTrackerURL string ExternalTrackerURL string
TrackerURLFormat string TrackerURLFormat string
TrackerIssueStyle string TrackerIssueStyle string
EnableProjects bool EnableCloseIssuesViaCommitInAnyBranch bool
EnablePulls bool EnableProjects bool
PullsIgnoreWhitespace bool EnablePulls bool
PullsAllowMerge bool PullsIgnoreWhitespace bool
PullsAllowRebase bool PullsAllowMerge bool
PullsAllowRebaseMerge bool PullsAllowRebase bool
PullsAllowSquash bool PullsAllowRebaseMerge bool
PullsAllowManualMerge bool PullsAllowSquash bool
EnableAutodetectManualMerge bool PullsAllowManualMerge bool
EnableTimetracker bool EnableAutodetectManualMerge bool
AllowOnlyContributorsToTrackTime bool EnableTimetracker bool
EnableIssueDependencies bool AllowOnlyContributorsToTrackTime bool
IsArchived bool EnableIssueDependencies bool
IsArchived bool
// Signing Settings // Signing Settings
TrustModel string TrustModel string
// Admin settings // Admin settings
EnableHealthCheck bool EnableHealthCheck bool
EnableCloseIssuesViaCommitInAnyBranch bool
} }
// Validate validates the fields // Validate validates the fields

View file

@ -216,6 +216,7 @@ func SettingsPost(ctx *context.Context) {
ctx.Redirect(repo.Link() + "/settings") ctx.Redirect(repo.Link() + "/settings")
case "advanced": case "advanced":
var repoChanged bool
var units []models.RepoUnit var units []models.RepoUnit
var deleteUnitTypes []models.UnitType var deleteUnitTypes []models.UnitType
@ -223,6 +224,11 @@ func SettingsPost(ctx *context.Context) {
// as an error on the UI for this action // as an error on the UI for this action
ctx.Data["Err_RepoName"] = nil ctx.Data["Err_RepoName"] = nil
if repo.CloseIssuesViaCommitInAnyBranch != form.EnableCloseIssuesViaCommitInAnyBranch {
repo.CloseIssuesViaCommitInAnyBranch = form.EnableCloseIssuesViaCommitInAnyBranch
repoChanged = true
}
if form.EnableWiki && form.EnableExternalWiki && !models.UnitTypeExternalWiki.UnitGlobalDisabled() { if form.EnableWiki && form.EnableExternalWiki && !models.UnitTypeExternalWiki.UnitGlobalDisabled() {
if !validation.IsValidExternalURL(form.ExternalWikiURL) { if !validation.IsValidExternalURL(form.ExternalWikiURL) {
ctx.Flash.Error(ctx.Tr("repo.settings.external_wiki_url_error")) ctx.Flash.Error(ctx.Tr("repo.settings.external_wiki_url_error"))
@ -326,6 +332,12 @@ func SettingsPost(ctx *context.Context) {
ctx.ServerError("UpdateRepositoryUnits", err) ctx.ServerError("UpdateRepositoryUnits", err)
return return
} }
if repoChanged {
if err := models.UpdateRepository(repo, false); err != nil {
ctx.ServerError("UpdateRepository", err)
return
}
}
log.Trace("Repository advanced settings updated: %s/%s", ctx.Repo.Owner.Name, repo.Name) log.Trace("Repository advanced settings updated: %s/%s", ctx.Repo.Owner.Name, repo.Name)
ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success")) ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success"))
@ -361,10 +373,6 @@ func SettingsPost(ctx *context.Context) {
repo.IsFsckEnabled = form.EnableHealthCheck repo.IsFsckEnabled = form.EnableHealthCheck
} }
if repo.CloseIssuesViaCommitInAnyBranch != form.EnableCloseIssuesViaCommitInAnyBranch {
repo.CloseIssuesViaCommitInAnyBranch = form.EnableCloseIssuesViaCommitInAnyBranch
}
if err := models.UpdateRepository(repo, false); err != nil { if err := models.UpdateRepository(repo, false); err != nil {
ctx.ServerError("UpdateRepository", err) ctx.ServerError("UpdateRepository", err)
return return

View file

@ -221,12 +221,16 @@
</div> </div>
</div> </div>
{{end}} {{end}}
<div class="field"> <div class="field">
<div class="ui checkbox"> <div class="ui checkbox">
<input name="enable_issue_dependencies" type="checkbox" {{if (.Repository.IsDependenciesEnabled)}}checked{{end}}> <input name="enable_issue_dependencies" type="checkbox" {{if (.Repository.IsDependenciesEnabled)}}checked{{end}}>
<label>{{.i18n.Tr "repo.issues.dependency.setting"}}</label> <label>{{.i18n.Tr "repo.issues.dependency.setting"}}</label>
</div>
</div> </div>
</div>
<div class="ui checkbox">
<input name="enable_close_issues_via_commit_in_any_branch" type="checkbox" {{ if .Repository.CloseIssuesViaCommitInAnyBranch }}checked{{end}}>
<label>{{.i18n.Tr "repo.settings.admin_enable_close_issues_via_commit_in_any_branch"}}</label>
</div>
</div> </div>
<div class="field"> <div class="field">
{{if .UnitTypeExternalTracker.UnitGlobalDisabled}} {{if .UnitTypeExternalTracker.UnitGlobalDisabled}}
@ -412,10 +416,6 @@
<label>{{.i18n.Tr "repo.settings.admin_enable_health_check"}}</label> <label>{{.i18n.Tr "repo.settings.admin_enable_health_check"}}</label>
</div> </div>
</div> </div>
<div class="ui checkbox">
<input name="enable_close_issues_via_commit_in_any_branch" type="checkbox" {{ if .Repository.CloseIssuesViaCommitInAnyBranch }}checked{{end}}>
<label>{{.i18n.Tr "repo.settings.admin_enable_close_issues_via_commit_in_any_branch"}}</label>
</div>
<div class="ui divider"></div> <div class="ui divider"></div>
<div class="field"> <div class="field">