forked from gitea/gitea
Backport #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:
parent
1fbc56d732
commit
0495544b8a
|
@ -170,6 +170,7 @@ type FindReleasesOptions struct {
|
||||||
IsPreRelease util.OptionalBool
|
IsPreRelease util.OptionalBool
|
||||||
IsDraft util.OptionalBool
|
IsDraft util.OptionalBool
|
||||||
TagNames []string
|
TagNames []string
|
||||||
|
HasSha1 util.OptionalBool // useful to find draft releases which are created with existing tags
|
||||||
}
|
}
|
||||||
|
|
||||||
func (opts *FindReleasesOptions) toConds(repoID int64) builder.Cond {
|
func (opts *FindReleasesOptions) toConds(repoID int64) builder.Cond {
|
||||||
|
@ -191,6 +192,13 @@ func (opts *FindReleasesOptions) toConds(repoID int64) builder.Cond {
|
||||||
if !opts.IsDraft.IsNone() {
|
if !opts.IsDraft.IsNone() {
|
||||||
cond = cond.And(builder.Eq{"is_draft": opts.IsDraft.IsTrue()})
|
cond = cond.And(builder.Eq{"is_draft": opts.IsDraft.IsTrue()})
|
||||||
}
|
}
|
||||||
|
if !opts.HasSha1.IsNone() {
|
||||||
|
if opts.HasSha1.IsTrue() {
|
||||||
|
cond = cond.And(builder.Neq{"sha1": ""})
|
||||||
|
} else {
|
||||||
|
cond = cond.And(builder.Eq{"sha1": ""})
|
||||||
|
}
|
||||||
|
}
|
||||||
return cond
|
return cond
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -524,7 +524,9 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["NumTags"], err = models.GetReleaseCountByRepoID(ctx.Repo.Repository.ID, models.FindReleasesOptions{
|
ctx.Data["NumTags"], err = models.GetReleaseCountByRepoID(ctx.Repo.Repository.ID, models.FindReleasesOptions{
|
||||||
|
IncludeDrafts: true,
|
||||||
IncludeTags: true,
|
IncludeTags: true,
|
||||||
|
HasSha1: util.OptionalBoolTrue, // only draft releases which are created with existing tags
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("GetReleaseCountByRepoID", err)
|
ctx.ServerError("GetReleaseCountByRepoID", err)
|
||||||
|
|
|
@ -117,8 +117,16 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
|
||||||
|
|
||||||
opts := models.FindReleasesOptions{
|
opts := models.FindReleasesOptions{
|
||||||
ListOptions: listOptions,
|
ListOptions: listOptions,
|
||||||
IncludeDrafts: writeAccess && !isTagList,
|
}
|
||||||
IncludeTags: isTagList,
|
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 := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, opts)
|
releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, opts)
|
||||||
|
|
|
@ -77,14 +77,12 @@
|
||||||
<span class="ui green label">{{$.i18n.Tr "repo.release.stable"}}</span>
|
<span class="ui green label">{{$.i18n.Tr "repo.release.stable"}}</span>
|
||||||
{{end}}
|
{{end}}
|
||||||
<span class="tag text blue">
|
<span class="tag text blue">
|
||||||
<a class="df ac je" href="{{if .IsDraft}}#{{else}}{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}{{end}}" rel="nofollow">{{svg "octicon-tag" 16 "mr-2"}}{{.TagName}}</a>
|
<a class="df ac je" href="{{if not .Sha1}}#{{else}}{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}{{end}}" rel="nofollow">{{svg "octicon-tag" 16 "mr-2"}}{{.TagName}}</a>
|
||||||
</span>
|
</span>
|
||||||
{{if not .IsDraft}}
|
{{if .Sha1}}
|
||||||
<span class="commit">
|
<span class="commit">
|
||||||
<a class="mono" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
|
<a class="mono" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
|
||||||
</span>
|
</span>
|
||||||
{{end}}
|
|
||||||
{{if .Sha1 }}
|
|
||||||
{{template "repo/branch_dropdown" dict "root" $ "release" .}}
|
{{template "repo/branch_dropdown" dict "root" $ "release" .}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in New Issue