aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/repo/release.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-09-10 19:30:37 +0200
committerGitHub <noreply@github.com>2021-09-10 19:30:37 +0200
commit77f604a9284887758e604e92d2c9b40697db0a23 (patch)
tree15b9d310d57af08ad5f286d07f8c54233f69611a /routers/web/repo/release.go
parent9ca0e7905c24f18ed246e65397589f0f41b50506 (diff)
downloadgitea-77f604a9284887758e604e92d2c9b40697db0a23.tar.gz
gitea-77f604a9284887758e604e92d2c9b40697db0a23.zip
Add skip and limit to git.GetTags (#16897)
* Make GetTags() api similar to GetBranches() * Use it for Tag/Release page
Diffstat (limited to 'routers/web/repo/release.go')
-rw-r--r--routers/web/repo/release.go25
1 files changed, 13 insertions, 12 deletions
diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go
index ef98790f52..0603f0ee97 100644
--- a/routers/web/repo/release.go
+++ b/routers/web/repo/release.go
@@ -83,7 +83,18 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
ctx.Data["PageIsTagList"] = false
}
- tags, err := ctx.Repo.GitRepo.GetTags()
+ listOptions := models.ListOptions{
+ Page: ctx.FormInt("page"),
+ PageSize: ctx.FormInt("limit"),
+ }
+ if listOptions.PageSize == 0 {
+ listOptions.PageSize = setting.Repository.Release.DefaultPagingNum
+ }
+ if listOptions.PageSize > setting.API.MaxResponseItems {
+ listOptions.PageSize = setting.API.MaxResponseItems
+ }
+
+ tags, err := ctx.Repo.GitRepo.GetTags(listOptions.GetStartEnd())
if err != nil {
ctx.ServerError("GetTags", err)
return
@@ -92,19 +103,9 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
writeAccess := ctx.Repo.CanWrite(models.UnitTypeReleases)
ctx.Data["CanCreateRelease"] = writeAccess && !ctx.Repo.Repository.IsArchived
- limit := ctx.FormInt("limit")
- if limit == 0 {
- limit = setting.Repository.Release.DefaultPagingNum
- }
- if limit > setting.API.MaxResponseItems {
- limit = setting.API.MaxResponseItems
- }
opts := models.FindReleasesOptions{
- ListOptions: models.ListOptions{
- Page: ctx.FormInt("page"),
- PageSize: limit,
- },
+ ListOptions: listOptions,
IncludeDrafts: writeAccess && !isTagList,
IncludeTags: isTagList,
}