aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/repo/release.go
diff options
context:
space:
mode:
authorJason Song <i@wolfogre.com>2022-10-03 20:05:53 +0800
committerGitHub <noreply@github.com>2022-10-03 20:05:53 +0800
commita08b48454970a0639039b730cbe616686e82bc0f (patch)
treee1e99706522b35ebab854c91a8a2a51adc56304a /routers/web/repo/release.go
parentaf849ac00965ed3e2722ed89309da4c353fd9bee (diff)
downloadgitea-a08b48454970a0639039b730cbe616686e82bc0f.tar.gz
gitea-a08b48454970a0639039b730cbe616686e82bc0f.zip
Tag list should include draft releases with existing tags (#21263)
Before, a tag for a draft release disappeared in the tag list, fix #21262. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers/web/repo/release.go')
-rw-r--r--routers/web/repo/release.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go
index 935813051a..1e5710fa98 100644
--- a/routers/web/repo/release.go
+++ b/routers/web/repo/release.go
@@ -117,9 +117,17 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
ctx.Data["CanCreateRelease"] = writeAccess && !ctx.Repo.Repository.IsArchived
opts := repo_model.FindReleasesOptions{
- ListOptions: listOptions,
- IncludeDrafts: writeAccess && !isTagList,
- IncludeTags: isTagList,
+ ListOptions: listOptions,
+ }
+ if isTagList {
+ // for the tags list page, show all releases with real tags (having real commit-id),
+ // the drafts should also be included because a real tag might be used as a draft.
+ opts.IncludeDrafts = true
+ opts.IncludeTags = true
+ opts.HasSha1 = util.OptionalBoolTrue
+ } else {
+ // only show draft releases for users who can write, read-only users shouldn't see draft releases.
+ opts.IncludeDrafts = writeAccess
}
releases, err := repo_model.GetReleasesByRepoID(ctx.Repo.Repository.ID, opts)