aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorparnic <github@parnic.com>2021-03-27 09:55:40 -0500
committerGitHub <noreply@github.com>2021-03-27 15:55:40 +0100
commitf4d27498bdc615605e14f783501e1d1256cd8d22 (patch)
tree8d04695b060bd8bac65b4a0d669628fe220a23e6 /models
parent6b836ac5f7546bc9ffb118b213dba92d3dd9ba8e (diff)
downloadgitea-f4d27498bdc615605e14f783501e1d1256cd8d22.tar.gz
gitea-f4d27498bdc615605e14f783501e1d1256cd8d22.zip
Add DefaultMergeStyle option to repository (#14789)
Fixes #12293
Diffstat (limited to 'models')
-rw-r--r--models/repo.go2
-rw-r--r--models/repo_unit.go10
2 files changed, 11 insertions, 1 deletions
diff --git a/models/repo.go b/models/repo.go
index 329e63cc42..c807916ddc 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -1086,7 +1086,7 @@ func CreateRepository(ctx DBContext, doer, u *User, repo *Repository, overwriteO
units = append(units, RepoUnit{
RepoID: repo.ID,
Type: tp,
- Config: &PullRequestsConfig{AllowMerge: true, AllowRebase: true, AllowRebaseMerge: true, AllowSquash: true},
+ Config: &PullRequestsConfig{AllowMerge: true, AllowRebase: true, AllowRebaseMerge: true, AllowSquash: true, DefaultMergeStyle: MergeStyleMerge},
})
} else {
units = append(units, RepoUnit{
diff --git a/models/repo_unit.go b/models/repo_unit.go
index 7702697ffa..1d54579a6e 100644
--- a/models/repo_unit.go
+++ b/models/repo_unit.go
@@ -102,6 +102,7 @@ type PullRequestsConfig struct {
AllowSquash bool
AllowManualMerge bool
AutodetectManualMerge bool
+ DefaultMergeStyle MergeStyle
}
// FromDB fills up a PullRequestsConfig from serialized format.
@@ -125,6 +126,15 @@ func (cfg *PullRequestsConfig) IsMergeStyleAllowed(mergeStyle MergeStyle) bool {
mergeStyle == MergeStyleManuallyMerged && cfg.AllowManualMerge
}
+// GetDefaultMergeStyle returns the default merge style for this pull request
+func (cfg *PullRequestsConfig) GetDefaultMergeStyle() MergeStyle {
+ if len(cfg.DefaultMergeStyle) != 0 {
+ return cfg.DefaultMergeStyle
+ }
+
+ return MergeStyleMerge
+}
+
// AllowedMergeStyleCount returns the total count of allowed merge styles for the PullRequestsConfig
func (cfg *PullRequestsConfig) AllowedMergeStyleCount() int {
count := 0