aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--custom/conf/app.example.ini3
-rw-r--r--docs/content/doc/advanced/config-cheat-sheet.en-us.md1
-rw-r--r--models/repo.go2
-rw-r--r--models/repo/repo_unit.go5
-rw-r--r--modules/setting/repository.go3
-rw-r--r--routers/install/install.go2
6 files changed, 15 insertions, 1 deletions
diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini
index 03bdf45350..9a50564769 100644
--- a/custom/conf/app.example.ini
+++ b/custom/conf/app.example.ini
@@ -948,6 +948,9 @@ PATH =
;; List of keywords used in Pull Request comments to automatically reopen a related issue
;REOPEN_KEYWORDS = reopen,reopens,reopened
;;
+;; Set default merge style for repository creating, valid options: merge, rebase, rebase-merge, squash
+;DEFAULT_MERGE_STYLE = merge
+;;
;; In the default merge message for squash commits include at most this many commits
;DEFAULT_MERGE_MESSAGE_COMMITS_LIMIT = 50
;;
diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md
index 9d7f6c126c..2dae3526f9 100644
--- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md
+++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md
@@ -92,6 +92,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
keywords used in Pull Request comments to automatically close a related issue
- `REOPEN_KEYWORDS`: **reopen**, **reopens**, **reopened**: List of keywords used in Pull Request comments to automatically reopen
a related issue
+- `DEFAULT_MERGE_STYLE`: **merge**: Set default merge style for repository creating, valid options: `merge`, `rebase`, `rebase-merge`, `squash`
- `DEFAULT_MERGE_MESSAGE_COMMITS_LIMIT`: **50**: In the default merge message for squash commits include at most this many commits. Set to `-1` to include all commits
- `DEFAULT_MERGE_MESSAGE_SIZE`: **5120**: In the default merge message for squash commits limit the size of the commit messages. Set to `-1` to have no limit. Only used if `POPULATE_SQUASH_COMMENT_WITH_COMMIT_MESSAGES` is `true`.
- `DEFAULT_MERGE_MESSAGE_ALL_AUTHORS`: **false**: In the default merge message for squash commits walk all commits to include all authors in the Co-authored-by otherwise just use those in the limited list
diff --git a/models/repo.go b/models/repo.go
index d2ad560948..bf70295275 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -373,7 +373,7 @@ func CreateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_
units = append(units, repo_model.RepoUnit{
RepoID: repo.ID,
Type: tp,
- Config: &repo_model.PullRequestsConfig{AllowMerge: true, AllowRebase: true, AllowRebaseMerge: true, AllowSquash: true, DefaultMergeStyle: repo_model.MergeStyleMerge, AllowRebaseUpdate: true},
+ Config: &repo_model.PullRequestsConfig{AllowMerge: true, AllowRebase: true, AllowRebaseMerge: true, AllowSquash: true, DefaultMergeStyle: repo_model.MergeStyle(setting.Repository.PullRequest.DefaultMergeStyle), AllowRebaseUpdate: true},
})
} else {
units = append(units, repo_model.RepoUnit{
diff --git a/models/repo/repo_unit.go b/models/repo/repo_unit.go
index a73678c6ef..8c17d6138c 100644
--- a/models/repo/repo_unit.go
+++ b/models/repo/repo_unit.go
@@ -11,6 +11,7 @@ import (
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/unit"
"code.gitea.io/gitea/modules/json"
+ "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"
"xorm.io/xorm"
@@ -148,6 +149,10 @@ func (cfg *PullRequestsConfig) GetDefaultMergeStyle() MergeStyle {
return cfg.DefaultMergeStyle
}
+ if setting.Repository.PullRequest.DefaultMergeStyle != "" {
+ return MergeStyle(setting.Repository.PullRequest.DefaultMergeStyle)
+ }
+
return MergeStyleMerge
}
diff --git a/modules/setting/repository.go b/modules/setting/repository.go
index bae4ad1be9..0b90fbc67c 100644
--- a/modules/setting/repository.go
+++ b/modules/setting/repository.go
@@ -71,6 +71,7 @@ var (
WorkInProgressPrefixes []string
CloseKeywords []string
ReopenKeywords []string
+ DefaultMergeStyle string
DefaultMergeMessageCommitsLimit int
DefaultMergeMessageSize int
DefaultMergeMessageAllAuthors bool
@@ -192,6 +193,7 @@ var (
WorkInProgressPrefixes []string
CloseKeywords []string
ReopenKeywords []string
+ DefaultMergeStyle string
DefaultMergeMessageCommitsLimit int
DefaultMergeMessageSize int
DefaultMergeMessageAllAuthors bool
@@ -205,6 +207,7 @@ var (
// https://help.github.com/articles/closing-issues-via-commit-messages
CloseKeywords: strings.Split("close,closes,closed,fix,fixes,fixed,resolve,resolves,resolved", ","),
ReopenKeywords: strings.Split("reopen,reopens,reopened", ","),
+ DefaultMergeStyle: "merge",
DefaultMergeMessageCommitsLimit: 50,
DefaultMergeMessageSize: 5 * 1024,
DefaultMergeMessageAllAuthors: false,
diff --git a/routers/install/install.go b/routers/install/install.go
index 3fc5f0536a..bf95cae1c6 100644
--- a/routers/install/install.go
+++ b/routers/install/install.go
@@ -456,6 +456,8 @@ func SubmitInstall(ctx *context.Context) {
cfg.Section("log").Key("ROOT_PATH").SetValue(form.LogRootPath)
cfg.Section("log").Key("ROUTER").SetValue("console")
+ cfg.Section("repository.pull-request").Key("DEFAULT_MERGE_STYLE").SetValue("merge")
+
cfg.Section("repository.signing").Key("DEFAULT_TRUST_MODEL").SetValue("committer")
cfg.Section("security").Key("INSTALL_LOCK").SetValue("true")