mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-19 17:01:12 +00:00
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:
parent
c081f20776
commit
16a0c97fbf
2 changed files with 25 additions and 18 deletions
|
@ -29,7 +29,7 @@ func ShowReleaseFeed(ctx *context.Context, repo *repo_model.Repository, isReleas
|
||||||
|
|
||||||
if isReleasesOnly {
|
if isReleasesOnly {
|
||||||
title = ctx.Locale.TrString("repo.release.releases_for", repo.FullName())
|
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 {
|
} else {
|
||||||
title = ctx.Locale.TrString("repo.release.tags_for", repo.FullName())
|
title = ctx.Locale.TrString("repo.release.tags_for", repo.FullName())
|
||||||
link = &feeds.Link{Href: repo.HTMLURL() + "/tags"}
|
link = &feeds.Link{Href: repo.HTMLURL() + "/tags"}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -27,50 +28,56 @@ func TestReleaseFeed(t *testing.T) {
|
||||||
t.Run("RSS feed", func(t *testing.T) {
|
t.Run("RSS feed", func(t *testing.T) {
|
||||||
defer tests.PrintCurrentTest(t)()
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
resp := MakeRequest(t, NewRequest(t, "GET", "/user2/repo1/releases.rss"), http.StatusOK)
|
releasesPath := "/user2/repo1/releases"
|
||||||
assert.Equal(t, `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
|
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>
|
<channel>
|
||||||
<title>Releases for user2/repo1</title>
|
<title>Releases for user2/repo1</title>
|
||||||
<link>http://localhost/user2/repo1/release</link>
|
<link>http://localhost%[1]s</link>
|
||||||
<description></description>
|
<description></description>
|
||||||
<pubDate></pubDate>
|
<pubDate></pubDate>
|
||||||
<item>
|
<item>
|
||||||
<title>pre-release</title>
|
<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>
|
<description></description>
|
||||||
<content:encoded><![CDATA[<p dir="auto">some text for a pre release</p>
|
<content:encoded><![CDATA[<p dir="auto">some text for a pre release</p>
|
||||||
]]></content:encoded>
|
]]></content:encoded>
|
||||||
<author>user2</author>
|
<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>
|
<pubDate></pubDate>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<title>testing-release</title>
|
<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>
|
<description></description>
|
||||||
<author>user2</author>
|
<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>
|
<pubDate></pubDate>
|
||||||
</item>
|
</item>
|
||||||
</channel>
|
</channel>
|
||||||
</rss>`, normalize(resp.Body.String()))
|
</rss>`, releasesPath), normalize(resp.Body.String()))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Atom feed", func(t *testing.T) {
|
t.Run("Atom feed", func(t *testing.T) {
|
||||||
defer tests.PrintCurrentTest(t)()
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
resp := MakeRequest(t, NewRequest(t, "GET", "/user2/repo1/releases.atom"), http.StatusOK)
|
releasesPath := "/user2/repo1/releases"
|
||||||
assert.Equal(t, `<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
|
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>
|
<title>Releases for user2/repo1</title>
|
||||||
<id>http://localhost/user2/repo1/release</id>
|
<id>http://localhost%[1]s</id>
|
||||||
<updated></updated>
|
<updated></updated>
|
||||||
<link href="http://localhost/user2/repo1/release"></link>
|
<link href="http://localhost%[1]s"></link>
|
||||||
<entry>
|
<entry>
|
||||||
<title>pre-release</title>
|
<title>pre-release</title>
|
||||||
<updated></updated>
|
<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"><p dir="auto">some text for a pre release</p>
</content>
|
<content type="html"><p dir="auto">some text for a pre release</p>
</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>
|
<author>
|
||||||
<name>user2</name>
|
<name>user2</name>
|
||||||
<email>user2@noreply.example.org</email>
|
<email>user2@noreply.example.org</email>
|
||||||
|
@ -79,13 +86,13 @@ func TestReleaseFeed(t *testing.T) {
|
||||||
<entry>
|
<entry>
|
||||||
<title>testing-release</title>
|
<title>testing-release</title>
|
||||||
<updated></updated>
|
<updated></updated>
|
||||||
<id>1: http://localhost/user2/repo1/releases/tag/v1.1</id>
|
<id>1: http://localhost%[1]s/tag/v1.1</id>
|
||||||
<link href="http://localhost/user2/repo1/releases/tag/v1.1" rel="alternate"></link>
|
<link href="http://localhost%[1]s/tag/v1.1" rel="alternate"></link>
|
||||||
<author>
|
<author>
|
||||||
<name>user2</name>
|
<name>user2</name>
|
||||||
<email>user2@noreply.example.org</email>
|
<email>user2@noreply.example.org</email>
|
||||||
</author>
|
</author>
|
||||||
</entry>
|
</entry>
|
||||||
</feed>`, normalize(resp.Body.String()))
|
</feed>`, releasesPath), normalize(resp.Body.String()))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue