Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move repo.CloseIssuesViaCommitInAnyBranch to issue settings #14965

Merged
merged 3 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions modules/forms/repo_form.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,34 +141,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
Expand Down
16 changes: 12 additions & 4 deletions routers/repo/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,19 @@ func SettingsPost(ctx *context.Context) {
ctx.Redirect(repo.Link() + "/settings")

case "advanced":
var repoChanged bool
var units []models.RepoUnit
var deleteUnitTypes []models.UnitType

// This section doesn't require repo_name/RepoName to be set in the form, don't show it
// 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"))
Expand Down Expand Up @@ -333,6 +339,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"))
Expand Down Expand Up @@ -368,10 +380,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
Expand Down
18 changes: 9 additions & 9 deletions templates/repo/settings/options.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,16 @@
</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}}
Expand Down Expand Up @@ -412,10 +416,6 @@
<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">
Expand Down