summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorElias Norberg <elias@aisle.se>2019-09-30 04:33:40 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2019-09-30 10:33:40 +0800
commit668d3d02aa0222c839e42bc2608ad1fa05b8640b (patch)
treeaf433d57ee30c76fa12303a873b15a0ed7d4b3b1 /services
parent0d2566b5608461e782d9e257a731afa753ab4a06 (diff)
downloadgitea-668d3d02aa0222c839e42bc2608ad1fa05b8640b.tar.gz
gitea-668d3d02aa0222c839e42bc2608ad1fa05b8640b.zip
If no specific context is required for status check, require an overall success (#8318)
Signed-off-by: Elias Norberg <elias@aisle.se>
Diffstat (limited to 'services')
-rw-r--r--services/pull/commit_status.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/services/pull/commit_status.go b/services/pull/commit_status.go
index bdadc329d6..2872db7bd2 100644
--- a/services/pull/commit_status.go
+++ b/services/pull/commit_status.go
@@ -8,12 +8,20 @@ package pull
import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
-
"github.com/pkg/errors"
)
// IsCommitStatusContextSuccess returns true if all required status check contexts succeed.
func IsCommitStatusContextSuccess(commitStatuses []*models.CommitStatus, requiredContexts []string) bool {
+ // If no specific context is required, require that last commit status is a success
+ if len(requiredContexts) == 0 {
+ status := models.CalcCommitStatus(commitStatuses)
+ if status == nil || status.State != models.CommitStatusSuccess {
+ return false
+ }
+ return true
+ }
+
for _, ctx := range requiredContexts {
var found bool
for _, commitStatus := range commitStatuses {