Skip to content

Commit a88f366

Browse files
authored
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
1 parent 8cdb666 commit a88f366

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,7 @@ pulls.data_broken = This pull request is broken due to missing fork information.
10981098
pulls.files_conflicted = This pull request has changes conflicting with the target branch.
10991099
pulls.is_checking = "Merge conflict checking is in progress. Try again in few moments."
11001100
pulls.required_status_check_failed = Some required checks were not successful.
1101+
pulls.required_status_check_missing = Some required checks are missing.
11011102
pulls.required_status_check_administrator = As an administrator, you may still merge this pull request.
11021103
pulls.blocked_by_approvals = "This Pull Request doesn't have enough approvals yet. %d of %d approvals granted."
11031104
pulls.blocked_by_rejection = "This Pull Request has changes requested by an official reviewer."

routers/repo/pull.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
451451
}
452452
return false
453453
}
454-
state := pull_service.MergeRequiredContextsCommitStatus(commitStatuses, pull.ProtectedBranch.StatusCheckContexts)
455-
ctx.Data["RequiredStatusCheckState"] = state
456-
ctx.Data["IsRequiredStatusCheckSuccess"] = state.IsSuccess()
454+
ctx.Data["RequiredStatusCheckState"] = pull_service.MergeRequiredContextsCommitStatus(commitStatuses, pull.ProtectedBranch.StatusCheckContexts)
457455
}
458456

459457
ctx.Data["HeadBranchMovedOn"] = headBranchSha != sha

templates/repo/issue/view_content/pull.tmpl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
{{- else if .IsBlockedByApprovals}}red
6868
{{- else if .IsBlockedByRejection}}red
6969
{{- else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsFailure .RequiredStatusCheckState.IsError)}}red
70-
{{- else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsPending .RequiredStatusCheckState.IsWarning)}}yellow
70+
{{- else if and .EnableStatusCheck (or (not $.LatestCommitStatus) .RequiredStatusCheckState.IsPending .RequiredStatusCheckState.IsWarning)}}yellow
7171
{{- else if and .RequireSigned (not .WillSign)}}}red
7272
{{- else if .Issue.PullRequest.IsChecking}}yellow
7373
{{- else if .Issue.PullRequest.CanAutoMerge}}green
@@ -143,6 +143,11 @@
143143
<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
144144
{{$.i18n.Tr "repo.pulls.required_status_check_failed"}}
145145
</div>
146+
{{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}}
147+
<div class="item text red">
148+
<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
149+
{{$.i18n.Tr "repo.pulls.required_status_check_missing"}}
150+
</div>
146151
{{else if and .RequireSigned (not .WillSign)}}
147152
<div class="item text red">
148153
<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
@@ -153,7 +158,7 @@
153158
{{$.i18n.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason) }}
154159
</div>
155160
{{end}}
156-
{{$notAllOverridableChecksOk := or .IsBlockedByApprovals .IsBlockedByRejection (and .EnableStatusCheck (not .IsRequiredStatusCheckSuccess))}}
161+
{{$notAllOverridableChecksOk := or .IsBlockedByApprovals .IsBlockedByRejection (and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess))}}
157162
{{if and (or $.IsRepoAdmin (not $notAllOverridableChecksOk)) (or (not .RequireSigned) .WillSign)}}
158163
{{if $notAllOverridableChecksOk}}
159164
<div class="item text yellow">
@@ -337,7 +342,7 @@
337342
{{svg "octicon-x" 16}}
338343
{{$.i18n.Tr "repo.pulls.blocked_by_rejection"}}
339344
</div>
340-
{{else if and .EnableStatusCheck (not .IsRequiredStatusCheckSuccess)}}
345+
{{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}}
341346
<div class="item text red">
342347
{{svg "octicon-x" 16}}
343348
{{$.i18n.Tr "repo.pulls.required_status_check_failed"}}

0 commit comments

Comments
 (0)