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}}
{{svg "octicon-git-merge" 32}}
- {{template "repo/pulls/status" .}}
{{if .Issue.PullRequest.HasMerged}}
@@ -143,6 +143,11 @@ {{svg "octicon-x" 16}} {{$.i18n.Tr "repo.pulls.required_status_check_failed"}}
+ {{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}} +
+ {{svg "octicon-x" 16}} + {{$.i18n.Tr "repo.pulls.required_status_check_missing"}} +
{{else if and .RequireSigned (not .WillSign)}}
{{svg "octicon-x" 16}} From b0ae16b6245710b37d4e50a4a3ca7e374cf588ab Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 15 Apr 2020 01:35:42 +0200 Subject: [PATCH 3/5] Update templates/repo/issue/view_content/pull.tmpl --- templates/repo/issue/view_content/pull.tmpl | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index f71f25b464aba..3fce4399c3b71 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -74,6 +74,7 @@ VARSTATUS: RequiredStatusCheckState.IsSuccess: {{if .RequiredStatusCheckState.Is {{- else if .Issue.PullRequest.CanAutoMerge}}green {{- else}}red{{end}}">{{svg "octicon-git-merge" 32}}
+ {{template "repo/pulls/status" .}}
{{if .Issue.PullRequest.HasMerged}}
From f24fc6b49a3bcbfb19eef5eeba9a001d64985975 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 15 Apr 2020 01:35:49 +0200 Subject: [PATCH 4/5] Update templates/repo/issue/view_content/pull.tmpl --- templates/repo/issue/view_content/pull.tmpl | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index 3fce4399c3b71..e8753ef179b5b 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -58,7 +58,6 @@
{{end}} -VARSTATUS: RequiredStatusCheckState.IsSuccess: {{if .RequiredStatusCheckState.IsSuccess}}true{{else}}false{{end}}