1
0
Fork 0

[GITEA] Check for Commit in opengraph

- It's possible that `PageIsDiff` is set but not `Commit` resulting in a
NPE in the template. This can happen when the requested commit doesn't exist.
- Regression of c802c46a9b &
5743d7cb5b
- Added 'hacky' integration test.

(cherry picked from commit 8db2d5e4a7)
(cherry picked from commit 8c737a802b)
(cherry picked from commit 6b7c7d18dc)
(cherry picked from commit a2be4fab27)
(cherry picked from commit a1125268ac)
This commit is contained in:
Gusted 2024-01-04 23:29:28 +01:00 committed by Earl Warren
parent f90b802634
commit 159dc74ceb
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -683,7 +683,12 @@ func TestCommitView(t *testing.T) {
defer tests.PrintCurrentTest(t)()
req := NewRequest(t, "GET", "/user2/repo1/commit/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
MakeRequest(t, req, http.StatusNotFound)
req.SetHeader("Accept", "text/html")
resp := MakeRequest(t, req, http.StatusNotFound)
// Really ensure that 404 is being sent back.
doc := NewHTMLParser(t, resp.Body)
doc.AssertElement(t, `[aria-label="Page Not Found"]`, true)
})
t.Run("Too short commit ID", func(t *testing.T) {