summaryrefslogtreecommitdiffstats
path: root/routers/web
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
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')
-rw-r--r--routers/web/repo/compare.go6
-rw-r--r--routers/web/repo/release.go25
2 files changed, 16 insertions, 15 deletions
diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go
index eb6c37a1a6..0a0b38f078 100644
--- a/routers/web/repo/compare.go
+++ b/routers/web/repo/compare.go
@@ -606,7 +606,7 @@ func getBranchesAndTagsForRepo(user *models.User, repo *models.Repository) (bool
if err != nil {
return false, nil, nil, err
}
- tags, err := gitRepo.GetTags()
+ tags, err := gitRepo.GetTags(0, 0)
if err != nil {
return false, nil, nil, err
}
@@ -632,7 +632,7 @@ func CompareDiff(ctx *context.Context) {
}
baseGitRepo := ctx.Repo.GitRepo
- baseTags, err := baseGitRepo.GetTags()
+ baseTags, err := baseGitRepo.GetTags(0, 0)
if err != nil {
ctx.ServerError("GetTags", err)
return
@@ -646,7 +646,7 @@ func CompareDiff(ctx *context.Context) {
}
ctx.Data["HeadBranches"] = headBranches
- headTags, err := headGitRepo.GetTags()
+ headTags, err := headGitRepo.GetTags(0, 0)
if err != nil {
ctx.ServerError("GetTags", err)
return
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,
}