diff options
author | Lanre Adelowo <adelowomailbox@gmail.com> | 2019-02-10 20:27:19 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-02-10 21:27:19 +0200 |
commit | 9d8178b3ac5f86a64f67ab7b5dea99347a5afe72 (patch) | |
tree | ed560142815927211f7d52db859728b88f0d9734 /models/migrations | |
parent | c0adb5ea8bd0b2551a8c414b54ef5bc67882de55 (diff) | |
download | gitea-9d8178b3ac5f86a64f67ab7b5dea99347a5afe72.tar.gz gitea-9d8178b3ac5f86a64f67ab7b5dea99347a5afe72.zip |
Add option to close issues via commit on a non master branch (#5992)
* fixes #5957
* add tests to make sure config option is respected
* use already defined struct
* - use migration to make the flag repo wide not for the entire gitea instance
Also note that the config value can still be set so as to be able to control the value for new repositories that are to be created
- fix copy/paste error in copyright header year and rearrange import
- use repo config instead of server config value to determine if a commit should close an issue
- update testsuite
* use global config only when creating a new repository
* allow repo admin toggle feature via UI
* fix typo and improve testcase
* fix fixtures
* add DEFAULT prefix to config value
* fix test
Diffstat (limited to 'models/migrations')
-rw-r--r-- | models/migrations/migrations.go | 2 | ||||
-rw-r--r-- | models/migrations/v79.go | 27 |
2 files changed, 29 insertions, 0 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 533ff90738..174e7b5156 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -210,6 +210,8 @@ var migrations = []Migration{ NewMigration("add theme to users", addUserDefaultTheme), // v78 -> v79 NewMigration("rename repo is_bare to repo is_empty", renameRepoIsBareToIsEmpty), + // v79 -> v80 + NewMigration("add can close issues via commit in any branch", addCanCloseIssuesViaCommitInAnyBranch), } // Migrate database to current version diff --git a/models/migrations/v79.go b/models/migrations/v79.go new file mode 100644 index 0000000000..e246393957 --- /dev/null +++ b/models/migrations/v79.go @@ -0,0 +1,27 @@ +// Copyright 2019 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package migrations + +import ( + "code.gitea.io/gitea/modules/setting" + + "github.com/go-xorm/xorm" +) + +func addCanCloseIssuesViaCommitInAnyBranch(x *xorm.Engine) error { + + type Repository struct { + ID int64 `xorm:"pk autoincr"` + CloseIssuesViaCommitInAnyBranch bool `xorm:"NOT NULL DEFAULT false"` + } + + if err := x.Sync2(new(Repository)); err != nil { + return err + } + + _, err := x.Exec("UPDATE repository SET close_issues_via_commit_in_any_branch = ?", + setting.Repository.DefaultCloseIssuesViaCommitsInAnyBranch) + return err +} |