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:
Sean Yangandwxiaoguang authored and GitHub committed 2026-09-23 14:34:19 +00:00
1 parent 08149f9bec
commit 191287d8be
10 files changed
+73 -17

No files matched your search

+4
View File
@@ -31,6 +31,7 @@ import (
"gitea.dev/modules/web"
"gitea.dev/modules/web/middleware"
"gitea.dev/routers"
"gitea.dev/routers/common"
gitea_context "gitea.dev/services/context"
"gitea.dev/tests"
@@ -289,6 +290,9 @@ func MakeRequest(t testing.TB, rw *RequestWrapper, expectedStatus int) *httptest
// don't use "require" which exits the test case and makes "wait group" wait forever
assert.Equal(t, expectedStatus, recorder.Code, "Request: %s %s", req.Method, req.URL.String())
}
if expectedStatus != http.StatusInternalServerError {
assert.NotContains(t, recorder.Body.String(), common.PageInternalServerErrorMark, "Request: %s %s, response should not contain internal server error", req.Method, req.URL.String())
}
}
return recorder
}