fix: correct release link in feed (#8802)

Resolves forgejo/forgejo#8793

## Checklist

The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org).

### Tests

- I added test coverage for Go changes...
  - [ ] in their respective `*_test.go` for unit tests.
  - [x] in the `tests/integration` directory if it involves interactions with a live Forgejo server.

### Release notes

- [ ] I do not want this change to show in the release notes.
- [x] I want the title to show in the release notes with a link to this pull request.
- [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title.

<!--start release-notes-assistant-->

## Release notes
<!--URL:https://codeberg.org/forgejo/forgejo-->
- Bug fixes
  - [PR](https://codeberg.org/forgejo/forgejo/pulls/8802): <!--number 8802 --><!--line 0 --><!--description Y29ycmVjdCByZWxlYXNlIGxpbmsgaW4gZmVlZA==-->correct release link in feed<!--description-->
<!--end release-notes-assistant-->

Co-authored-by: Gusted <postmaster@gusted.xyz>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8802
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
Earl Warren 2025-08-06 17:51:36 +02:00 committed by Earl Warren
commit 16a0c97fbf
2 changed files with 25 additions and 18 deletions

View file

@ -29,7 +29,7 @@ func ShowReleaseFeed(ctx *context.Context, repo *repo_model.Repository, isReleas
if isReleasesOnly {
title = ctx.Locale.TrString("repo.release.releases_for", repo.FullName())
link = &feeds.Link{Href: repo.HTMLURL() + "/release"}
link = &feeds.Link{Href: repo.HTMLURL() + "/releases"}
} else {
title = ctx.Locale.TrString("repo.release.tags_for", repo.FullName())
link = &feeds.Link{Href: repo.HTMLURL() + "/tags"}

View file

@ -4,6 +4,7 @@
package integration
import (
"fmt"
"net/http"
"regexp"
"testing"
@ -27,50 +28,56 @@ func TestReleaseFeed(t *testing.T) {
t.Run("RSS feed", func(t *testing.T) {
defer tests.PrintCurrentTest(t)()
resp := MakeRequest(t, NewRequest(t, "GET", "/user2/repo1/releases.rss"), http.StatusOK)
assert.Equal(t, `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
releasesPath := "/user2/repo1/releases"
MakeRequest(t, NewRequest(t, "GET", releasesPath), http.StatusOK)
resp := MakeRequest(t, NewRequest(t, "GET", releasesPath+".rss"), http.StatusOK)
assert.Equal(t, fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>Releases for user2/repo1</title>
<link>http://localhost/user2/repo1/release</link>
<link>http://localhost%[1]s</link>
<description></description>
<pubDate></pubDate>
<item>
<title>pre-release</title>
<link>http://localhost/user2/repo1/releases/tag/v1.0</link>
<link>http://localhost%[1]s/tag/v1.0</link>
<description></description>
<content:encoded><![CDATA[<p dir="auto">some text for a pre release</p>
]]></content:encoded>
<author>user2</author>
<guid>5: http://localhost/user2/repo1/releases/tag/v1.0</guid>
<guid>5: http://localhost%[1]s/tag/v1.0</guid>
<pubDate></pubDate>
</item>
<item>
<title>testing-release</title>
<link>http://localhost/user2/repo1/releases/tag/v1.1</link>
<link>http://localhost%[1]s/tag/v1.1</link>
<description></description>
<author>user2</author>
<guid>1: http://localhost/user2/repo1/releases/tag/v1.1</guid>
<guid>1: http://localhost%[1]s/tag/v1.1</guid>
<pubDate></pubDate>
</item>
</channel>
</rss>`, normalize(resp.Body.String()))
</rss>`, releasesPath), normalize(resp.Body.String()))
})
t.Run("Atom feed", func(t *testing.T) {
defer tests.PrintCurrentTest(t)()
resp := MakeRequest(t, NewRequest(t, "GET", "/user2/repo1/releases.atom"), http.StatusOK)
assert.Equal(t, `<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
releasesPath := "/user2/repo1/releases"
MakeRequest(t, NewRequest(t, "GET", releasesPath), http.StatusOK)
resp := MakeRequest(t, NewRequest(t, "GET", releasesPath+".atom"), http.StatusOK)
assert.Equal(t, fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
<title>Releases for user2/repo1</title>
<id>http://localhost/user2/repo1/release</id>
<id>http://localhost%[1]s</id>
<updated></updated>
<link href="http://localhost/user2/repo1/release"></link>
<link href="http://localhost%[1]s"></link>
<entry>
<title>pre-release</title>
<updated></updated>
<id>5: http://localhost/user2/repo1/releases/tag/v1.0</id>
<id>5: http://localhost%[1]s/tag/v1.0</id>
<content type="html">&lt;p dir=&#34;auto&#34;&gt;some text for a pre release&lt;/p&gt;&#xA;</content>
<link href="http://localhost/user2/repo1/releases/tag/v1.0" rel="alternate"></link>
<link href="http://localhost%[1]s/tag/v1.0" rel="alternate"></link>
<author>
<name>user2</name>
<email>user2@noreply.example.org</email>
@ -79,13 +86,13 @@ func TestReleaseFeed(t *testing.T) {
<entry>
<title>testing-release</title>
<updated></updated>
<id>1: http://localhost/user2/repo1/releases/tag/v1.1</id>
<link href="http://localhost/user2/repo1/releases/tag/v1.1" rel="alternate"></link>
<id>1: http://localhost%[1]s/tag/v1.1</id>
<link href="http://localhost%[1]s/tag/v1.1" rel="alternate"></link>
<author>
<name>user2</name>
<email>user2@noreply.example.org</email>
</author>
</entry>
</feed>`, normalize(resp.Body.String()))
</feed>`, releasesPath), normalize(resp.Body.String()))
})
}