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 @@ -200,6 +200,7 @@ type FindReleasesOptions struct {
200200 IsPreRelease util.OptionalBool
201201 IsDraft util.OptionalBool
202202 TagNames []string
203+ HasSha1 util.OptionalBool // useful to find draft releases which are created with existing tags
203204}
204205
205206func (opts * FindReleasesOptions ) toConds (repoID int64 ) builder.Cond {
@@ -221,6 +222,13 @@ func (opts *FindReleasesOptions) toConds(repoID int64) builder.Cond {
221222 if ! opts .IsDraft .IsNone () {
222223 cond = cond .And (builder.Eq {"is_draft" : opts .IsDraft .IsTrue ()})
223224 }
225+ if ! opts .HasSha1 .IsNone () {
226+ if opts .HasSha1 .IsTrue () {
227+ cond = cond .And (builder.Neq {"sha1" : "" })
228+ } else {
229+ cond = cond .And (builder.Eq {"sha1" : "" })
230+ }
231+ }
224232 return cond
225233}
226234
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 = repo_model .GetReleaseCountByRepoID (ctx .Repo .Repository .ID , repo_model.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 @@ -117,9 +117,17 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
117117 ctx .Data ["CanCreateRelease" ] = writeAccess && ! ctx .Repo .Repository .IsArchived
118118
119119 opts := repo_model.FindReleasesOptions {
120- ListOptions : listOptions ,
121- IncludeDrafts : writeAccess && ! isTagList ,
122- IncludeTags : isTagList ,
120+ ListOptions : listOptions ,
121+ }
122+ if isTagList {
123+ // for the tags list page, show all releases with real tags (having real commit-id),
124+ // the drafts should also be included because a real tag might be used as a draft.
125+ opts .IncludeDrafts = true
126+ opts .IncludeTags = true
127+ opts .HasSha1 = util .OptionalBoolTrue
128+ } else {
129+ // only show draft releases for users who can write, read-only users shouldn't see draft releases.
130+ opts .IncludeDrafts = writeAccess
123131 }
124132
125133 releases , err := repo_model .GetReleasesByRepoID (ctx .Repo .Repository .ID , opts )
Original file line number Diff line number Diff line change 7777 <span class="ui green label">{{$.locale.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