File tree 4 files changed +24
-8
lines changed 4 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,7 @@ type FindReleasesOptions struct {
170
170
IsPreRelease util.OptionalBool
171
171
IsDraft util.OptionalBool
172
172
TagNames []string
173
+ HasSha1 util.OptionalBool // useful to find draft releases which are created with existing tags
173
174
}
174
175
175
176
func (opts * FindReleasesOptions ) toConds (repoID int64 ) builder.Cond {
@@ -191,6 +192,13 @@ func (opts *FindReleasesOptions) toConds(repoID int64) builder.Cond {
191
192
if ! opts .IsDraft .IsNone () {
192
193
cond = cond .And (builder.Eq {"is_draft" : opts .IsDraft .IsTrue ()})
193
194
}
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
+ }
194
202
return cond
195
203
}
196
204
Original file line number Diff line number Diff line change @@ -524,7 +524,9 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
524
524
}
525
525
526
526
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
528
530
})
529
531
if err != nil {
530
532
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) {
116
116
ctx .Data ["CanCreateRelease" ] = writeAccess && ! ctx .Repo .Repository .IsArchived
117
117
118
118
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
122
130
}
123
131
124
132
releases , err := models .GetReleasesByRepoID (ctx .Repo .Repository .ID , opts )
Original file line number Diff line number Diff line change 77
77
<span class="ui green label">{{$.i18n.Tr "repo.release.stable"}}</span>
78
78
{{end}}
79
79
<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>
81
81
</span>
82
- {{if not .IsDraft }}
82
+ {{if .Sha1 }}
83
83
<span class="commit">
84
84
<a class="mono" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "mr-2"}}{{ShortSha .Sha1}}</a>
85
85
</span>
86
- {{end}}
87
- {{if .Sha1 }}
88
86
{{template "repo/branch_dropdown" dict "root" $ "release" .}}
89
87
{{end}}
90
88
{{end}}
You can’t perform that action at this time.
0 commit comments