]> source.dussan.org Git - gitea.git/commitdiff
Move repo.CloseIssuesViaCommitInAnyBranch to issue settings (#14965)
authorNorwin <noerw@users.noreply.github.com>
Tue, 16 Mar 2021 01:00:52 +0000 (01:00 +0000)
committerGitHub <noreply@github.com>
Tue, 16 Mar 2021 01:00:52 +0000 (02:00 +0100)
modules/forms/repo_form.go
routers/repo/setting.go
templates/repo/settings/options.tmpl

index 6cf72ee6b89df91eb2f6a7f050485253072d7bb5..6c7c9bea138d8cad625764ec7eb2ac6dee7eeb14 100644 (file)
@@ -123,34 +123,34 @@ type RepoSettingForm struct {
        EnablePrune    bool
 
        // Advanced settings
-       EnableWiki                       bool
-       EnableExternalWiki               bool
-       ExternalWikiURL                  string
-       EnableIssues                     bool
-       EnableExternalTracker            bool
-       ExternalTrackerURL               string
-       TrackerURLFormat                 string
-       TrackerIssueStyle                string
-       EnableProjects                   bool
-       EnablePulls                      bool
-       PullsIgnoreWhitespace            bool
-       PullsAllowMerge                  bool
-       PullsAllowRebase                 bool
-       PullsAllowRebaseMerge            bool
-       PullsAllowSquash                 bool
-       PullsAllowManualMerge            bool
-       EnableAutodetectManualMerge      bool
-       EnableTimetracker                bool
-       AllowOnlyContributorsToTrackTime bool
-       EnableIssueDependencies          bool
-       IsArchived                       bool
+       EnableWiki                            bool
+       EnableExternalWiki                    bool
+       ExternalWikiURL                       string
+       EnableIssues                          bool
+       EnableExternalTracker                 bool
+       ExternalTrackerURL                    string
+       TrackerURLFormat                      string
+       TrackerIssueStyle                     string
+       EnableCloseIssuesViaCommitInAnyBranch bool
+       EnableProjects                        bool
+       EnablePulls                           bool
+       PullsIgnoreWhitespace                 bool
+       PullsAllowMerge                       bool
+       PullsAllowRebase                      bool
+       PullsAllowRebaseMerge                 bool
+       PullsAllowSquash                      bool
+       PullsAllowManualMerge                 bool
+       EnableAutodetectManualMerge           bool
+       EnableTimetracker                     bool
+       AllowOnlyContributorsToTrackTime      bool
+       EnableIssueDependencies               bool
+       IsArchived                            bool
 
        // Signing Settings
        TrustModel string
 
        // Admin settings
-       EnableHealthCheck                     bool
-       EnableCloseIssuesViaCommitInAnyBranch bool
+       EnableHealthCheck bool
 }
 
 // Validate validates the fields
index 6b31ac4c71adbf1f1b5da8b881c9935bc24104eb..3c7524e4e6938319bd5c238258cc7c65a520977b 100644 (file)
@@ -216,6 +216,7 @@ func SettingsPost(ctx *context.Context) {
                ctx.Redirect(repo.Link() + "/settings")
 
        case "advanced":
+               var repoChanged bool
                var units []models.RepoUnit
                var deleteUnitTypes []models.UnitType
 
@@ -223,6 +224,11 @@ func SettingsPost(ctx *context.Context) {
                // as an error on the UI for this action
                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 !validation.IsValidExternalURL(form.ExternalWikiURL) {
                                ctx.Flash.Error(ctx.Tr("repo.settings.external_wiki_url_error"))
@@ -326,6 +332,12 @@ func SettingsPost(ctx *context.Context) {
                        ctx.ServerError("UpdateRepositoryUnits", err)
                        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)
 
                ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success"))
@@ -361,10 +373,6 @@ func SettingsPost(ctx *context.Context) {
                        repo.IsFsckEnabled = form.EnableHealthCheck
                }
 
-               if repo.CloseIssuesViaCommitInAnyBranch != form.EnableCloseIssuesViaCommitInAnyBranch {
-                       repo.CloseIssuesViaCommitInAnyBranch = form.EnableCloseIssuesViaCommitInAnyBranch
-               }
-
                if err := models.UpdateRepository(repo, false); err != nil {
                        ctx.ServerError("UpdateRepository", err)
                        return
index 9d87101671ffbf88bb03aa78cef5f6d7406e8c9d..f944eb8d8dea01bc8c9113f7e0b21f527357ada7 100644 (file)
                                                                </div>
                                                        </div>
                                                {{end}}
-                                                       <div class="field">
-                                                               <div class="ui checkbox">
-                                                                       <input name="enable_issue_dependencies" type="checkbox" {{if (.Repository.IsDependenciesEnabled)}}checked{{end}}>
-                                                                       <label>{{.i18n.Tr "repo.issues.dependency.setting"}}</label>
-                                                               </div>
+                                               <div class="field">
+                                                       <div class="ui checkbox">
+                                                               <input name="enable_issue_dependencies" type="checkbox" {{if (.Repository.IsDependenciesEnabled)}}checked{{end}}>
+                                                               <label>{{.i18n.Tr "repo.issues.dependency.setting"}}</label>
                                                        </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 class="field">
                                                {{if .UnitTypeExternalTracker.UnitGlobalDisabled}}
                                                <label>{{.i18n.Tr "repo.settings.admin_enable_health_check"}}</label>
                                        </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="field">