Skip to content

Commit 1bf7b8d

Browse files
authored
Fix signing.wont_sign.%!s(<nil>) if Require Signing commits but not signed in (#12581)
signing.wont_sign.%!s(<nil>) will be displayed if the repository needs signed commits but the user is not logged in. This is displayed because of complicated logic in the the template repo/issue/view_content/pull.tmpl and a shortcut in the code of routers/repo/issue.go This PR adds a default value of notsignedin if users are not signed in, which although our templates will not show will prevent custom templates from showing the above. It also fixes the template to avoid showing signing errors if the user is not authorized to sign. Replaces #12564 Close #12564 Signed-off-by: Andrew Thornton <[email protected]>
1 parent dd8ec12 commit 1bf7b8d

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,7 @@ signing.wont_sign.basesigned = The merge will not be signed as the base commit i
12761276
signing.wont_sign.headsigned = The merge will not be signed as the head commit is not signed
12771277
signing.wont_sign.commitssigned = The merge will not be signed as all the associated commits are not signed
12781278
signing.wont_sign.approved = The merge will not be signed as the PR is not approved
1279+
signing.wont_sign.not_signed_in = You are not signed in
12791280
12801281
ext_wiki = Ext. Wiki
12811282
ext_wiki.desc = Link to an external wiki.

routers/repo/issue.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,8 @@ func ViewIssue(ctx *context.Context) {
12121212
log.Error("Error whilst checking if could sign pr %d in repo %s. Error: %v", pull.ID, pull.BaseRepo.FullName(), err)
12131213
}
12141214
}
1215+
} else {
1216+
ctx.Data["WontSignReason"] = "not_signed_in"
12151217
}
12161218
ctx.Data["IsPullBranchDeletable"] = canDelete &&
12171219
pull.HeadRepo != nil &&

templates/repo/issue/view_content/pull.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
{{- else if .IsBlockedByOutdatedBranch}}red
7474
{{- else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsFailure .RequiredStatusCheckState.IsError)}}red
7575
{{- else if and .EnableStatusCheck (or (not $.LatestCommitStatus) .RequiredStatusCheckState.IsPending .RequiredStatusCheckState.IsWarning)}}yellow
76-
{{- else if and .RequireSigned (not .WillSign)}}red
76+
{{- else if and .AllowMerge .RequireSigned (not .WillSign)}}red
7777
{{- else if .Issue.PullRequest.IsChecking}}yellow
7878
{{- else if .Issue.PullRequest.CanAutoMerge}}green
7979
{{- else}}red{{end}}">{{svg "octicon-git-merge" 32}}</a>
@@ -159,7 +159,7 @@
159159
<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
160160
{{$.i18n.Tr "repo.pulls.required_status_check_missing"}}
161161
</div>
162-
{{else if and .RequireSigned (not .WillSign)}}
162+
{{else if and .AllowMerge .RequireSigned (not .WillSign)}}
163163
<div class="item text red">
164164
<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
165165
{{$.i18n.Tr "repo.pulls.require_signed_wont_sign"}}
@@ -170,7 +170,7 @@
170170
</div>
171171
{{end}}
172172
{{$notAllOverridableChecksOk := or .IsBlockedByApprovals .IsBlockedByRejection .IsBlockedByOutdatedBranch (and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess))}}
173-
{{if and (or $.IsRepoAdmin (not $notAllOverridableChecksOk)) (or (not .RequireSigned) .WillSign)}}
173+
{{if and (or $.IsRepoAdmin (not $notAllOverridableChecksOk)) (or (not .AllowMerge) (not .RequireSigned) .WillSign)}}
174174
{{if $notAllOverridableChecksOk}}
175175
<div class="item text yellow">
176176
<i class="icon icon-octicon">{{svg "octicon-dot-fill" 16}}</i>
@@ -216,7 +216,7 @@
216216
</div>
217217
{{end}}
218218

219-
{{if and (or $.IsRepoAdmin (not $notAllOverridableChecksOk)) (or (not .RequireSigned) .WillSign)}}
219+
{{if and (or $.IsRepoAdmin (not $notAllOverridableChecksOk)) (or (not .AllowMerge) (not .RequireSigned) .WillSign)}}
220220
{{if .AllowMerge}}
221221
{{$prUnit := .Repository.MustGetUnit $.UnitTypePullRequests}}
222222
{{$approvers := .Issue.PullRequest.GetApprovers}}

0 commit comments

Comments
 (0)