From 16a0c97fbf0255e632d0ea2244bf02a4dad0703a Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 6 Aug 2025 17:51:36 +0200 Subject: [PATCH] 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/.md` to be be used for the release notes instead of the title. ## Release notes - Bug fixes - [PR](https://codeberg.org/forgejo/forgejo/pulls/8802): correct release link in feed Co-authored-by: Gusted Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8802 Reviewed-by: Gusted Co-authored-by: Earl Warren Co-committed-by: Earl Warren --- routers/web/feed/release.go | 2 +- tests/integration/release_feed_test.go | 41 +++++++++++++++----------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/routers/web/feed/release.go b/routers/web/feed/release.go index 646241c021..d24fa6ecc7 100644 --- a/routers/web/feed/release.go +++ b/routers/web/feed/release.go @@ -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"} diff --git a/tests/integration/release_feed_test.go b/tests/integration/release_feed_test.go index e1781e343e..eded0459c8 100644 --- a/tests/integration/release_feed_test.go +++ b/tests/integration/release_feed_test.go @@ -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, ` + 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(` Releases for user2/repo1 - http://localhost/user2/repo1/release + http://localhost%[1]s pre-release - http://localhost/user2/repo1/releases/tag/v1.0 + http://localhost%[1]s/tag/v1.0 some text for a pre release

]]>
user2 - 5: http://localhost/user2/repo1/releases/tag/v1.0 + 5: http://localhost%[1]s/tag/v1.0
testing-release - http://localhost/user2/repo1/releases/tag/v1.1 + http://localhost%[1]s/tag/v1.1 user2 - 1: http://localhost/user2/repo1/releases/tag/v1.1 + 1: http://localhost%[1]s/tag/v1.1
-
`, normalize(resp.Body.String())) +
`, 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, ` + 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(` Releases for user2/repo1 - http://localhost/user2/repo1/release + http://localhost%[1]s - + pre-release - 5: http://localhost/user2/repo1/releases/tag/v1.0 + 5: http://localhost%[1]s/tag/v1.0 <p dir="auto">some text for a pre release</p> - + user2 user2@noreply.example.org @@ -79,13 +86,13 @@ func TestReleaseFeed(t *testing.T) { testing-release - 1: http://localhost/user2/repo1/releases/tag/v1.1 - + 1: http://localhost%[1]s/tag/v1.1 + user2 user2@noreply.example.org -`, normalize(resp.Body.String())) +`, releasesPath), normalize(resp.Body.String())) }) }