@@ -15,6 +15,7 @@ import (
1515 "code.gitea.io/gitea/models/db"
1616 user_model "code.gitea.io/gitea/models/user"
1717 "code.gitea.io/gitea/modules/container"
18+ "code.gitea.io/gitea/modules/optional"
1819 "code.gitea.io/gitea/modules/structs"
1920 "code.gitea.io/gitea/modules/timeutil"
2021 "code.gitea.io/gitea/modules/util"
@@ -228,10 +229,10 @@ type FindReleasesOptions struct {
228229 RepoID int64
229230 IncludeDrafts bool
230231 IncludeTags bool
231- IsPreRelease util. OptionalBool
232- IsDraft util. OptionalBool
232+ IsPreRelease optional. Option [ bool ]
233+ IsDraft optional. Option [ bool ]
233234 TagNames []string
234- HasSha1 util. OptionalBool // useful to find draft releases which are created with existing tags
235+ HasSha1 optional. Option [ bool ] // useful to find draft releases which are created with existing tags
235236}
236237
237238func (opts FindReleasesOptions ) ToConds () builder.Cond {
@@ -246,14 +247,14 @@ func (opts FindReleasesOptions) ToConds() builder.Cond {
246247 if len (opts .TagNames ) > 0 {
247248 cond = cond .And (builder .In ("tag_name" , opts .TagNames ))
248249 }
249- if ! opts .IsPreRelease .IsNone () {
250- cond = cond .And (builder.Eq {"is_prerelease" : opts .IsPreRelease .IsTrue ()})
250+ if opts .IsPreRelease .Has () {
251+ cond = cond .And (builder.Eq {"is_prerelease" : opts .IsPreRelease .Value ()})
251252 }
252- if ! opts .IsDraft .IsNone () {
253- cond = cond .And (builder.Eq {"is_draft" : opts .IsDraft .IsTrue ()})
253+ if opts .IsDraft .Has () {
254+ cond = cond .And (builder.Eq {"is_draft" : opts .IsDraft .Value ()})
254255 }
255- if ! opts .HasSha1 .IsNone () {
256- if opts .HasSha1 .IsTrue () {
256+ if opts .HasSha1 .Has () {
257+ if opts .HasSha1 .Value () {
257258 cond = cond .And (builder.Neq {"sha1" : "" })
258259 } else {
259260 cond = cond .And (builder.Eq {"sha1" : "" })
@@ -275,7 +276,7 @@ func GetTagNamesByRepoID(ctx context.Context, repoID int64) ([]string, error) {
275276 ListOptions : listOptions ,
276277 IncludeDrafts : true ,
277278 IncludeTags : true ,
278- HasSha1 : util . OptionalBoolTrue ,
279+ HasSha1 : optional . Some ( true ) ,
279280 RepoID : repoID ,
280281 }
281282
0 commit comments