diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go
index 19b83915afdfc..284fd27abf72b 100644
--- a/routers/web/repo/release.go
+++ b/routers/web/repo/release.go
@@ -295,6 +295,7 @@ func SingleRelease(ctx *context.Context) {
}
ctx.Data["PageIsSingleTag"] = release.IsTag
+ ctx.Data["SingleReleaseTagName"] = release.TagName
if release.IsTag {
ctx.Data["Title"] = release.TagName
} else {
diff --git a/services/context/repo.go b/services/context/repo.go
index 6c348b99cbfab..ef54b9cee88c7 100644
--- a/services/context/repo.go
+++ b/services/context/repo.go
@@ -56,7 +56,6 @@ type Repository struct {
// RefFullName is the full ref name that the user is viewing
RefFullName git.RefName
BranchName string // it is the RefFullName's short name if its type is "branch"
- TagName string // it is the RefFullName's short name if its type is "tag"
TreePath string
// Commit it is always set to the commit for the branch or tag, or just the commit that the user is viewing
@@ -851,7 +850,6 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) {
ctx.Repo.CommitID = ctx.Repo.Commit.ID.String()
} else if refType == git.RefTypeTag && ctx.Repo.GitRepo.IsTagExist(refShortName) {
ctx.Repo.RefFullName = git.RefNameFromTag(refShortName)
- ctx.Repo.TagName = refShortName
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetTagCommit(refShortName)
if err != nil {
@@ -901,8 +899,6 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) {
ctx.Data["BranchName"] = ctx.Repo.BranchName
- ctx.Data["TagName"] = ctx.Repo.TagName
-
ctx.Data["CommitID"] = ctx.Repo.CommitID
ctx.Data["CanCreateBranch"] = ctx.Repo.CanCreateBranch() // only used by the branch selector dropdown: AllowCreateNewRef
diff --git a/templates/repo/release_tag_header.tmpl b/templates/repo/release_tag_header.tmpl
index f96c76864f163..fb17cf44c43da 100644
--- a/templates/repo/release_tag_header.tmpl
+++ b/templates/repo/release_tag_header.tmpl
@@ -17,7 +17,7 @@
{{end}}
{{if and (not .PageIsTagList) .CanCreateRelease}}
-
+
{{ctx.Locale.Tr "repo.release.new_release"}}
{{end}}
diff --git a/tests/integration/release_test.go b/tests/integration/release_test.go
index d3c4ed6a83eda..1a7f9e38b5173 100644
--- a/tests/integration/release_test.go
+++ b/tests/integration/release_test.go
@@ -173,17 +173,25 @@ func TestViewReleaseListNoLogin(t *testing.T) {
}, commitsToMain)
}
-func TestViewSingleReleaseNoLogin(t *testing.T) {
+func TestViewSingleRelease(t *testing.T) {
defer tests.PrepareTestEnv(t)()
- req := NewRequest(t, "GET", "/user2/repo-release/releases/tag/v1.0")
- resp := MakeRequest(t, req, http.StatusOK)
-
- htmlDoc := NewHTMLParser(t, resp.Body)
- // check the "number of commits to main since this release"
- releaseList := htmlDoc.doc.Find("#release-list .ahead > a")
- assert.EqualValues(t, 1, releaseList.Length())
- assert.EqualValues(t, "3 commits", releaseList.First().Text())
+ t.Run("NoLogin", func(t *testing.T) {
+ req := NewRequest(t, "GET", "/user2/repo-release/releases/tag/v1.0")
+ resp := MakeRequest(t, req, http.StatusOK)
+ htmlDoc := NewHTMLParser(t, resp.Body)
+ // check the "number of commits to main since this release"
+ releaseList := htmlDoc.doc.Find("#release-list .ahead > a")
+ assert.EqualValues(t, 1, releaseList.Length())
+ assert.EqualValues(t, "3 commits", releaseList.First().Text())
+ })
+ t.Run("Login", func(t *testing.T) {
+ session := loginUser(t, "user1")
+ req := NewRequest(t, "GET", "/user2/repo1/releases/tag/delete-tag") // "delete-tag" is the only one with is_tag=true (although strange name)
+ resp := session.MakeRequest(t, req, http.StatusOK)
+ // the New Release button should contain the tag name
+ assert.Contains(t, resp.Body.String(), ``)
+ })
}
func TestViewReleaseListLogin(t *testing.T) {