summaryrefslogtreecommitdiffstats
path: root/models/repo_unit.go
diff options
context:
space:
mode:
authorJimmy Praet <jimmy.praet@telenet.be>2020-11-22 14:58:12 +0100
committerGitHub <noreply@github.com>2020-11-22 15:58:12 +0200
commit2791cc139e809856f894cd9dfcfceb9c4a9b8865 (patch)
treeff44327a72e4aa42fca0a79d1bfdb80c4664f78c /models/repo_unit.go
parentde1e4b2da903c10687cf7d2e51ba4843796e17f2 (diff)
downloadgitea-2791cc139e809856f894cd9dfcfceb9c4a9b8865.tar.gz
gitea-2791cc139e809856f894cd9dfcfceb9c4a9b8865.zip
Don't show a dropdown menu when only 1 merge option is available (#13660) (#13670)
Diffstat (limited to 'models/repo_unit.go')
-rw-r--r--models/repo_unit.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/models/repo_unit.go b/models/repo_unit.go
index d4c74515f7..b208276d9d 100644
--- a/models/repo_unit.go
+++ b/models/repo_unit.go
@@ -113,6 +113,24 @@ func (cfg *PullRequestsConfig) IsMergeStyleAllowed(mergeStyle MergeStyle) bool {
mergeStyle == MergeStyleSquash && cfg.AllowSquash
}
+// AllowedMergeStyleCount returns the total count of allowed merge styles for the PullRequestsConfig
+func (cfg *PullRequestsConfig) AllowedMergeStyleCount() int {
+ count := 0
+ if cfg.AllowMerge {
+ count++
+ }
+ if cfg.AllowRebase {
+ count++
+ }
+ if cfg.AllowRebaseMerge {
+ count++
+ }
+ if cfg.AllowSquash {
+ count++
+ }
+ return count
+}
+
// BeforeSet is invoked from XORM before setting the value of a field of this object.
func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell) {
switch colName {