From 8b8759482c070b7e855dfdd084036081533fe99d Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Wed, 15 Apr 2020 01:11:44 +0200
Subject: [PATCH 1/5] refactor
---
routers/repo/pull.go | 4 +---
templates/repo/issue/view_content/pull.tmpl | 4 ++--
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index 00195fd02a1e3..63cc39865c06d 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 03ac1b6cd704d..eb260fa580d62 100644
--- a/templates/repo/issue/view_content/pull.tmpl
+++ b/templates/repo/issue/view_content/pull.tmpl
@@ -153,7 +153,7 @@
{{$.i18n.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason) }}
{{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}}
@@ -337,7 +337,7 @@
{{svg "octicon-x" 16}}
{{$.i18n.Tr "repo.pulls.blocked_by_rejection"}}
- {{else if and .EnableStatusCheck (not .IsRequiredStatusCheckSuccess)}}
+ {{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}}
{{svg "octicon-x" 16}}
{{$.i18n.Tr "repo.pulls.required_status_check_failed"}}
From 048e2b174fe1a8c53ef6a3ac4669ddf6c458027e Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Wed, 15 Apr 2020 01:12:01 +0200
Subject: [PATCH 2/5] add casse: missing StatusChecks
---
options/locale/locale_en-US.ini | 1 +
templates/repo/issue/view_content/pull.tmpl | 11 ++++++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index 8b43115c07a3b..cf1c547b03536 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/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl
index eb260fa580d62..f71f25b464aba 100644
--- a/templates/repo/issue/view_content/pull.tmpl
+++ b/templates/repo/issue/view_content/pull.tmpl
@@ -58,6 +58,7 @@
{{end}}
+VARSTATUS: RequiredStatusCheckState.IsSuccess: {{if .RequiredStatusCheckState.IsSuccess}}true{{else}}false{{end}}