Skip to content

Commit 98b92a1

Browse files
committed
allow repo admin toggle feature via UI
1 parent 4d61bef commit 98b92a1

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

modules/auth/repo_form.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
"github.com/Unknwon/com"
1616
"github.com/go-macaron/binding"
17-
"gopkg.in/macaron.v1"
17+
macaron "gopkg.in/macaron.v1"
1818
)
1919

2020
// _______________________________________ _________.______________________ _______________.___.
@@ -120,7 +120,8 @@ type RepoSettingForm struct {
120120
IsArchived bool
121121

122122
// Admin settings
123-
EnableHealthCheck bool
123+
EnableHealthCheck bool
124+
EnableCloseIssuesViaCommitInAnyBranch bool
124125
}
125126

126127
// Validate validates the fields

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ settings.pulls.allow_rebase_merge_commit = Enable Rebasing with explicit merge c
10351035
settings.pulls.allow_squash_commits = Enable Squashing to Merge Commits
10361036
settings.admin_settings = Administrator Settings
10371037
settings.admin_enable_health_check = Enable Repository Health Checks (git fsck)
1038+
settings.admin_enable_close_issues_via_commit_in_any_branch = Close an issue via a commit made in a non default branch
10381039
settings.danger_zone = Danger Zone
10391040
settings.new_owner_has_same_repo = The new owner already has a repository with same name. Please choose another name.
10401041
settings.convert = Convert to Regular Repository

routers/repo/setting.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,19 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
250250

251251
if repo.IsFsckEnabled != form.EnableHealthCheck {
252252
repo.IsFsckEnabled = form.EnableHealthCheck
253-
if err := models.UpdateRepository(repo, false); err != nil {
254-
ctx.ServerError("UpdateRepository", err)
255-
return
256-
}
257-
log.Trace("Repository admin settings updated: %s/%s", ctx.Repo.Owner.Name, repo.Name)
258253
}
259254

255+
if repo.CloseIssuesViaCommitInAnyBranch != form.EnableCloseIssuesViaCommitInAnyBranch {
256+
repo.CloseIssuesViaCommitInAnyBranch = form.EnableCloseIssuesViaCommitInAnyBranch
257+
}
258+
259+
if err := models.UpdateRepository(repo, false); err != nil {
260+
ctx.ServerError("UpdateRepository", err)
261+
return
262+
}
263+
264+
log.Trace("Repository admin settings updated: %s/%s", ctx.Repo.Owner.Name, repo.Name)
265+
260266
ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success"))
261267
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
262268

templates/repo/settings/options.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@
263263
<label>{{.i18n.Tr "repo.settings.admin_enable_health_check"}}</label>
264264
</div>
265265
</div>
266+
<div class="ui checkbox">
267+
<input name="enable_close_issues_via_commit_in_any_branch" type="checkbox" {{ if .Repository.CloseIssuesViaCommitInAnyBranch }}checked{{end}}>
268+
<label>{{.i18n.Tr "repo.settings.admin_enable_close_issues_via_commit_in_any_branch"}}</label>
269+
</div>
266270

267271
<div class="ui divider"></div>
268272
<div class="field">

0 commit comments

Comments
 (0)