mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-24 13:43:43 +09:00
fix(repo): commit page fails to render unsigned commits with a different committer (#39381)
Since #39229 the commit page header dereferences `.Verification.CommittingUser` when the committer is not the author. `Verification` is `nil` for unsigned commits (see `repo.Diff`), so opening such a commit — a rebased or cherry-picked one, for example — logs a template error and the page comes out truncated: ``` Render failed: failed to render template: repo/commit_page, error: template error: builtin(bindata):repo/commit_page:138:22 : executing "repo/commit_page" at <.Verification.CommittingUser>: nil pointer evaluating interface {}.CommittingUser ``` This guards the access and adds an integration test that creates a commit with distinct author and committer identities and checks the page renders completely (the status stays 200 on a mid-render failure, so the test looks at the body). _The fix was worked out with help from an AI assistant; I reviewed and tested it myself._ --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -135,7 +135,7 @@
|
||||
<span class="flex-text-inline tw-text-text-light">{{ctx.Locale.Tr "repo.diff.committed_at" $authors $committedAt}}</span>
|
||||
{{else}}
|
||||
{{$committerAvatar := ""}}{{$committerDisplayName := ""}}
|
||||
{{if .Verification.CommittingUser}}
|
||||
{{if and .Verification .Verification.CommittingUser}}
|
||||
{{$committerAvatar = ctx.AvatarUtils.Avatar .Verification.CommittingUser 20}}
|
||||
{{$committerDisplayName = HTMLFormat `%s%s` .Verification.CommittingUser.GetShortDisplayNameLinkHTML (ctx.RenderUtils.UserTypeLabel .Verification.CommittingUser)}}
|
||||
{{else}}
|
||||
|
||||
@@ -907,7 +907,6 @@
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{template "repo/settings/layout_footer" .}}
|
||||
|
||||
{{if $.CanManagerDangerZone}}
|
||||
{{if .Repository.IsMirror}}
|
||||
@@ -1083,3 +1082,5 @@
|
||||
{{end}}
|
||||
|
||||
{{template "repo/settings/push_mirror_sync_modal" .}}
|
||||
|
||||
{{template "repo/settings/layout_footer" .}}
|
||||
|
||||
Reference in New Issue
Block a user