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>
This commit is contained in:
Jason Song 2022-10-03 20:05:53 +08:00 committed by GitHub
parent af849ac009
commit a08b484549
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 8 deletions

View file

@ -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)