File tree Expand file tree Collapse file tree 4 files changed +24
-8
lines changed Expand file tree Collapse file tree 4 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,7 @@ type FindReleasesOptions struct {
170170 IsPreRelease util.OptionalBool
171171 IsDraft util.OptionalBool
172172 TagNames []string
173+ HasSha1 util.OptionalBool // useful to find draft releases which are created with existing tags
173174}
174175
175176func (opts * FindReleasesOptions ) toConds (repoID int64 ) builder.Cond {
@@ -191,6 +192,13 @@ func (opts *FindReleasesOptions) toConds(repoID int64) builder.Cond {
191192 if ! opts .IsDraft .IsNone () {
192193 cond = cond .And (builder.Eq {"is_draft" : opts .IsDraft .IsTrue ()})
193194 }
195+ if ! opts .HasSha1 .IsNone () {
196+ if opts .HasSha1 .IsTrue () {
197+ cond = cond .And (builder.Neq {"sha1" : "" })
198+ } else {
199+ cond = cond .And (builder.Eq {"sha1" : "" })
200+ }
201+ }
194202 return cond
195203}
196204
Original file line number Diff line number Diff line change @@ -524,7 +524,9 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
524524 }
525525
526526 ctx .Data ["NumTags" ], err = models .GetReleaseCountByRepoID (ctx .Repo .Repository .ID , models.FindReleasesOptions {
527- IncludeTags : true ,
527+ IncludeDrafts : true ,
528+ IncludeTags : true ,
529+ HasSha1 : util .OptionalBoolTrue , // only draft releases which are created with existing tags
528530 })
529531 if err != nil {
530532 ctx .ServerError ("GetReleaseCountByRepoID" , err )
Original file line number Diff line number Diff line change @@ -116,9 +116,17 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
116116 ctx .Data ["CanCreateRelease" ] = writeAccess && ! ctx .Repo .Repository .IsArchived
117117
118118 opts := models.FindReleasesOptions {
119- ListOptions : listOptions ,
120- IncludeDrafts : writeAccess && ! isTagList ,
121- IncludeTags : isTagList ,
119+ ListOptions : listOptions ,
120+ }
121+ if isTagList {
122+ // for the tags list page, show all releases with real tags (having real commit-id),
123+ // the drafts should also be included because a real tag might be used as a draft.
124+ opts .IncludeDrafts = true
125+ opts .IncludeTags = true
126+ opts .HasSha1 = util .OptionalBoolTrue
127+ } else {
128+ // only show draft releases for users who can write, read-only users shouldn't see draft releases.
129+ opts .IncludeDrafts = writeAccess
122130 }
123131
124132 releases , err := models .GetReleasesByRepoID (ctx .Repo .Repository .ID , opts )
Original file line number Diff line number Diff line change 7777 <span class="ui green label">{{$.i18n.Tr "repo.release.stable"}}</span>
7878 {{end}}
7979 <span class="tag text blue">
80- <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>
80+ <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>
8181 </span>
82- {{if not .IsDraft }}
82+ {{if .Sha1 }}
8383 <span class="commit">
8484 <a class="mono" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
8585 </span>
86- {{end}}
87- {{if .Sha1 }}
8886 {{template "repo/branch_dropdown" dict "root" $ "release" .}}
8987 {{end}}
9088 {{end}}
You can’t perform that action at this time.
0 commit comments