From c41b2c73ef21d5c54c7f2658ceffaa163b135131 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 2 Mar 2024 20:07:23 +0800 Subject: [PATCH 1/3] Display tag name as title for a tag with no release --- routers/web/repo/release.go | 8 ++++++++ templates/repo/release/list.tmpl | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index 1998bd8ccd..79f3181ba0 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -184,6 +184,11 @@ func Releases(ctx *context.Context) { ctx.ServerError("getReleaseInfos", err) return } + for _, rel := range releases { + if rel.Release.IsTag && rel.Release.Title == "" { + rel.Release.Title = rel.Release.TagName + } + } ctx.Data["Releases"] = releases @@ -295,6 +300,9 @@ func SingleRelease(ctx *context.Context) { } release := releases[0].Release + if release.IsTag && release.Title == "" { + release.Title = release.TagName + } ctx.Data["PageIsSingleTag"] = release.IsTag if release.IsTag { diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl index 6dbeb741db..826480e3fb 100644 --- a/templates/repo/release/list.tmpl +++ b/templates/repo/release/list.tmpl @@ -18,13 +18,13 @@

- {{$release.Title}} + {{if $.PageIsSingleTag}}{{$release.Title}}{{else}}{{$release.Title}}{{end}} {{template "repo/commit_statuses" dict "Status" $info.CommitStatus "Statuses" $info.CommitStatuses "AdditionalClasses" "gt-df"}} {{if $release.IsDraft}} {{ctx.Locale.Tr "repo.release.draft"}} {{else if $release.IsPrerelease}} {{ctx.Locale.Tr "repo.release.prerelease"}} - {{else}} + {{else if (not $release.IsTag)}} {{ctx.Locale.Tr "repo.release.stable"}} {{end}}

From 19ff532d4234e2063c1fc15547422b0b5337829b Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Mon, 4 Mar 2024 08:16:04 +0100 Subject: [PATCH 2/3] Test that tags without a release display properly Update the `TestTagViewWithoutRelease` test case with another assert: one that checks that the release title is properly displayed. Signed-off-by: Gergely Nagy --- tests/integration/repo_tag_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/integration/repo_tag_test.go b/tests/integration/repo_tag_test.go index 60c73ae63e..5a99453659 100644 --- a/tests/integration/repo_tag_test.go +++ b/tests/integration/repo_tag_test.go @@ -7,6 +7,7 @@ package integration import ( "net/http" "net/url" + "strings" "testing" "code.gitea.io/gitea/models" @@ -56,6 +57,13 @@ func TestTagViewWithoutRelease(t *testing.T) { // Test that the release sub-menu isn't active releaseLink := htmlDoc.Find(".small-menu-items .item[href*='/releases']") assert.False(t, releaseLink.HasClass("active")) + + // Test that the title is displayed + releaseTitle := strings.TrimSpace(htmlDoc.Find("h4.release-list-title").Text()) + assert.Equal(t, "no-release", releaseTitle) + + // Test that there is no "Stable" link + htmlDoc.AssertElement(t, "h4.release-list-title > span.ui.green.label", false) } func TestCreateNewTagProtected(t *testing.T) { From f9894f4c5147447fa2f38a1835a575fd38f54e75 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Mon, 4 Mar 2024 08:25:07 +0100 Subject: [PATCH 3/3] A release title should always be a link This partially reverts c41b2c73ef21d5c54c7f2658ceffaa163b135131: for the sake of consistency, the title of a release should always be a link, whether it's a tag-only release or not. Signed-off-by: Gergely Nagy --- templates/repo/release/list.tmpl | 2 +- tests/integration/repo_tag_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl index 826480e3fb..d533cf6757 100644 --- a/templates/repo/release/list.tmpl +++ b/templates/repo/release/list.tmpl @@ -18,7 +18,7 @@

- {{if $.PageIsSingleTag}}{{$release.Title}}{{else}}{{$release.Title}}{{end}} + {{$release.Title}} {{template "repo/commit_statuses" dict "Status" $info.CommitStatus "Statuses" $info.CommitStatuses "AdditionalClasses" "gt-df"}} {{if $release.IsDraft}} {{ctx.Locale.Tr "repo.release.draft"}} diff --git a/tests/integration/repo_tag_test.go b/tests/integration/repo_tag_test.go index 5a99453659..3fa3454343 100644 --- a/tests/integration/repo_tag_test.go +++ b/tests/integration/repo_tag_test.go @@ -59,7 +59,7 @@ func TestTagViewWithoutRelease(t *testing.T) { assert.False(t, releaseLink.HasClass("active")) // Test that the title is displayed - releaseTitle := strings.TrimSpace(htmlDoc.Find("h4.release-list-title").Text()) + releaseTitle := strings.TrimSpace(htmlDoc.Find("h4.release-list-title > a").Text()) assert.Equal(t, "no-release", releaseTitle) // Test that there is no "Stable" link