mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-04 07:17:35 +00:00
feat(api): add tag_filter query parameter to release list API (#38681)
Adds a `tag_filter` query parameter to `GET /repos/{owner}/{repo}/releases` that filters releases by tag name, with `*` as a wildcard (e.g. `v1*`, `*beta`, `*rc*`). Matching is
case-insensitive and done in the database query. Literal `%`, `_` and `\` in the filter are escaped.
Fixes: https://github.com/go-gitea/gitea/issues/38513
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
@@ -154,6 +154,10 @@ func ListReleases(ctx *context.APIContext) {
|
||||
// in: query
|
||||
// description: filter (exclude / include) pre-releases
|
||||
// type: boolean
|
||||
// - name: tag_filter
|
||||
// in: query
|
||||
// description: 'filter releases by tag. supports "*" as a wildcard (for example: v1*, *beta, *rc*).'
|
||||
// type: string
|
||||
// - name: page
|
||||
// in: query
|
||||
// description: page number of results to return (1-based)
|
||||
@@ -178,6 +182,7 @@ func ListReleases(ctx *context.APIContext) {
|
||||
IsDraft: ctx.FormOptionalBool("draft"),
|
||||
IsPreRelease: ctx.FormOptionalBool("pre-release"),
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
TagFilter: ctx.FormString("tag_filter"),
|
||||
}
|
||||
|
||||
releases, err := db.Find[repo_model.Release](ctx, opts)
|
||||
|
||||
Reference in New Issue
Block a user