mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
fix: Allow SHA-256 in PR commit URLs (#10309)
Closes #9129. I decided to try myself in contributing to Forgejo after having found this bug mentioned on Fedi. I have also added a basic test for this behaviour, but this means that this PR adds a SHA-256 repo to the fixture set, so it can be reused in other tests. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10309 Reviewed-by: Lucas <sclu1034@noreply.codeberg.org> Reviewed-by: 0ko <0ko@noreply.codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Nikita Karamov <me@kytta.dev> Co-committed-by: Nikita Karamov <me@kytta.dev>
This commit is contained in:
parent
0398fa85e1
commit
a22e5f86c6
46 changed files with 260 additions and 32 deletions
|
|
@ -62,6 +62,33 @@ func TestPullCommitLinks(t *testing.T) {
|
|||
assert.Equal(t, "/user2/repo1/pulls/3/commits/5f22f7d0d95d614d25a5b68592adb345a4b5c7fd", commitLinkHref)
|
||||
}
|
||||
|
||||
func TestPullCommitLinksSHA256(t *testing.T) {
|
||||
if !git.SupportHashSha256 {
|
||||
t.Skip("skipping because installed Git version doesn't support SHA256")
|
||||
return
|
||||
}
|
||||
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
req := NewRequest(t, "GET", "/user2/repo256/pulls/1/commits")
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
commitSha := htmlDoc.Find(".commit-list td.sha a.sha.label").First()
|
||||
commitShaHref, commitShaOk := commitSha.Attr("href")
|
||||
assert.True(t, commitShaOk)
|
||||
assert.Equal(t, "/user2/repo256/pulls/1/commits/004581b3bb63754502364664021404490ee747ce58e98d27c046f2e46f5f2f55", commitShaHref)
|
||||
|
||||
commitLink := htmlDoc.Find(".commit-list td.message a").First()
|
||||
commitLinkHref, commitLinkOk := commitLink.Attr("href")
|
||||
assert.True(t, commitLinkOk)
|
||||
assert.Equal(t, "/user2/repo256/pulls/1/commits/004581b3bb63754502364664021404490ee747ce58e98d27c046f2e46f5f2f55", commitLinkHref)
|
||||
|
||||
commitReq := NewRequest(t, "GET", commitShaHref)
|
||||
MakeRequest(t, commitReq, http.StatusOK)
|
||||
}
|
||||
|
||||
func TestPullCommitSignature(t *testing.T) {
|
||||
t.Cleanup(func() {
|
||||
// Cannot use t.Context(), it is in the done state.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue