File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import (
14
14
"code.gitea.io/gitea/modules/setting"
15
15
"code.gitea.io/gitea/modules/structs"
16
16
"code.gitea.io/gitea/modules/timeutil"
17
+ "code.gitea.io/gitea/modules/util"
17
18
18
19
"xorm.io/builder"
19
20
)
@@ -173,6 +174,8 @@ type FindReleasesOptions struct {
173
174
ListOptions
174
175
IncludeDrafts bool
175
176
IncludeTags bool
177
+ IsPreRelease util.OptionalBool
178
+ IsDraft util.OptionalBool
176
179
TagNames []string
177
180
}
178
181
@@ -189,6 +192,12 @@ func (opts *FindReleasesOptions) toConds(repoID int64) builder.Cond {
189
192
if len (opts .TagNames ) > 0 {
190
193
cond = cond .And (builder .In ("tag_name" , opts .TagNames ))
191
194
}
195
+ if ! opts .IsPreRelease .IsNone () {
196
+ cond = cond .And (builder.Eq {"is_prerelease" : opts .IsPreRelease .IsTrue ()})
197
+ }
198
+ if ! opts .IsDraft .IsNone () {
199
+ cond = cond .And (builder.Eq {"is_draft" : opts .IsDraft .IsTrue ()})
200
+ }
192
201
return cond
193
202
}
194
203
Original file line number Diff line number Diff line change @@ -83,6 +83,14 @@ func ListReleases(ctx *context.APIContext) {
83
83
// description: name of the repo
84
84
// type: string
85
85
// required: true
86
+ // - name: draft
87
+ // in: query
88
+ // description: filter (exclude / include) drafts, if you dont have repo write access none will show
89
+ // type: boolean
90
+ // - name: pre-release
91
+ // in: query
92
+ // description: filter (exclude / include) pre-releases
93
+ // type: boolean
86
94
// - name: per_page
87
95
// in: query
88
96
// description: page size of results, deprecated - use limit
@@ -100,14 +108,16 @@ func ListReleases(ctx *context.APIContext) {
100
108
// "200":
101
109
// "$ref": "#/responses/ReleaseList"
102
110
listOptions := utils .GetListOptions (ctx )
103
- if ctx .QueryInt ("per_page" ) != 0 {
111
+ if listOptions . PageSize == 0 && ctx .QueryInt ("per_page" ) != 0 {
104
112
listOptions .PageSize = ctx .QueryInt ("per_page" )
105
113
}
106
114
107
115
releases , err := models .GetReleasesByRepoID (ctx .Repo .Repository .ID , models.FindReleasesOptions {
108
116
ListOptions : listOptions ,
109
117
IncludeDrafts : ctx .Repo .AccessMode >= models .AccessModeWrite ,
110
118
IncludeTags : false ,
119
+ IsDraft : ctx .QueryOptionalBool ("draft" ),
120
+ IsPreRelease : ctx .QueryOptionalBool ("pre-release" ),
111
121
})
112
122
if err != nil {
113
123
ctx .Error (http .StatusInternalServerError , "GetReleasesByRepoID" , err )
Original file line number Diff line number Diff line change 8006
8006
"in": "path",
8007
8007
"required": true
8008
8008
},
8009
+ {
8010
+ "type": "boolean",
8011
+ "description": "filter (exclude / include) drafts, if you dont have repo write access none will show",
8012
+ "name": "draft",
8013
+ "in": "query"
8014
+ },
8015
+ {
8016
+ "type": "boolean",
8017
+ "description": "filter (exclude / include) pre-releases",
8018
+ "name": "pre-release",
8019
+ "in": "query"
8020
+ },
8009
8021
{
8010
8022
"type": "integer",
8011
8023
"description": "page size of results, deprecated - use limit",
You can’t perform that action at this time.
0 commit comments