aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-04-15 22:35:18 +0200
committerGitHub <noreply@github.com>2020-04-15 21:35:18 +0100
commita88f3663eb162f2a2558c3a957087a680bdd8ce6 (patch)
treefb0c113aa20c820578e2e28f86aaa716c040f913
parent8cdb6662c8154a840a1ba547599e2847a1b80d17 (diff)
downloadgitea-a88f3663eb162f2a2558c3a957087a680bdd8ce6.tar.gz
gitea-a88f3663eb162f2a2558c3a957087a680bdd8ce6.zip
Fix merge dialog on protected branch with missing required statuses (#11074)
It is possible for misconfigured protected branches to have required status checks that are not in any of the current statuses: Pending, Success, Error, Failure, or Warning - presumably because the CI has not contacted us as yet. Fix #10636 by adding case: missing StatusChecks when these are missing
-rw-r--r--options/locale/locale_en-US.ini1
-rw-r--r--routers/repo/pull.go4
-rw-r--r--templates/repo/issue/view_content/pull.tmpl11
3 files changed, 10 insertions, 6 deletions
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index 8b43115c07..cf1c547b03 100644
--- a/options/locale/locale_en-US.ini
+++ b/options/locale/locale_en-US.ini
@@ -1098,6 +1098,7 @@ pulls.data_broken = This pull request is broken due to missing fork information.
pulls.files_conflicted = This pull request has changes conflicting with the target branch.
pulls.is_checking = "Merge conflict checking is in progress. Try again in few moments."
pulls.required_status_check_failed = Some required checks were not successful.
+pulls.required_status_check_missing = Some required checks are missing.
pulls.required_status_check_administrator = As an administrator, you may still merge this pull request.
pulls.blocked_by_approvals = "This Pull Request doesn't have enough approvals yet. %d of %d approvals granted."
pulls.blocked_by_rejection = "This Pull Request has changes requested by an official reviewer."
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index 00195fd02a..63cc39865c 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -451,9 +451,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
}
return false
}
- state := pull_service.MergeRequiredContextsCommitStatus(commitStatuses, pull.ProtectedBranch.StatusCheckContexts)
- ctx.Data["RequiredStatusCheckState"] = state
- ctx.Data["IsRequiredStatusCheckSuccess"] = state.IsSuccess()
+ ctx.Data["RequiredStatusCheckState"] = pull_service.MergeRequiredContextsCommitStatus(commitStatuses, pull.ProtectedBranch.StatusCheckContexts)
}
ctx.Data["HeadBranchMovedOn"] = headBranchSha != sha
diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl
index 03ac1b6cd7..73a6d695ff 100644
--- a/templates/repo/issue/view_content/pull.tmpl
+++ b/templates/repo/issue/view_content/pull.tmpl
@@ -67,7 +67,7 @@
{{- else if .IsBlockedByApprovals}}red
{{- else if .IsBlockedByRejection}}red
{{- else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsFailure .RequiredStatusCheckState.IsError)}}red
- {{- else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsPending .RequiredStatusCheckState.IsWarning)}}yellow
+ {{- else if and .EnableStatusCheck (or (not $.LatestCommitStatus) .RequiredStatusCheckState.IsPending .RequiredStatusCheckState.IsWarning)}}yellow
{{- else if and .RequireSigned (not .WillSign)}}}red
{{- else if .Issue.PullRequest.IsChecking}}yellow
{{- else if .Issue.PullRequest.CanAutoMerge}}green
@@ -143,6 +143,11 @@
<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
{{$.i18n.Tr "repo.pulls.required_status_check_failed"}}
</div>
+ {{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}}
+ <div class="item text red">
+ <i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
+ {{$.i18n.Tr "repo.pulls.required_status_check_missing"}}
+ </div>
{{else if and .RequireSigned (not .WillSign)}}
<div class="item text red">
<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
@@ -153,7 +158,7 @@
{{$.i18n.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason) }}
</div>
{{end}}
- {{$notAllOverridableChecksOk := or .IsBlockedByApprovals .IsBlockedByRejection (and .EnableStatusCheck (not .IsRequiredStatusCheckSuccess))}}
+ {{$notAllOverridableChecksOk := or .IsBlockedByApprovals .IsBlockedByRejection (and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess))}}
{{if and (or $.IsRepoAdmin (not $notAllOverridableChecksOk)) (or (not .RequireSigned) .WillSign)}}
{{if $notAllOverridableChecksOk}}
<div class="item text yellow">
@@ -337,7 +342,7 @@
{{svg "octicon-x" 16}}
{{$.i18n.Tr "repo.pulls.blocked_by_rejection"}}
</div>
- {{else if and .EnableStatusCheck (not .IsRequiredStatusCheckSuccess)}}
+ {{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}}
<div class="item text red">
{{svg "octicon-x" 16}}
{{$.i18n.Tr "repo.pulls.required_status_check_failed"}}