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 @@ -200,6 +200,7 @@ type FindReleasesOptions struct {
200
200
IsPreRelease util.OptionalBool
201
201
IsDraft util.OptionalBool
202
202
TagNames []string
203
+ HasSha1 util.OptionalBool // useful to find draft releases which are created with existing tags
203
204
}
204
205
205
206
func (opts * FindReleasesOptions ) toConds (repoID int64 ) builder.Cond {
@@ -221,6 +222,13 @@ func (opts *FindReleasesOptions) toConds(repoID int64) builder.Cond {
221
222
if ! opts .IsDraft .IsNone () {
222
223
cond = cond .And (builder.Eq {"is_draft" : opts .IsDraft .IsTrue ()})
223
224
}
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
+ }
224
232
return cond
225
233
}
226
234
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 = 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
528
530
})
529
531
if err != nil {
530
532
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) {
117
117
ctx .Data ["CanCreateRelease" ] = writeAccess && ! ctx .Repo .Repository .IsArchived
118
118
119
119
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
123
131
}
124
132
125
133
releases , err := repo_model .GetReleasesByRepoID (ctx .Repo .Repository .ID , opts )
Original file line number Diff line number Diff line change 77
77
<span class="ui green label">{{$.locale.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