mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 11:52:10 +00:00
Add skip and limit to git.GetTags (#16897)
* Make GetTags() api similar to GetBranches() * Use it for Tag/Release page
This commit is contained in:
parent
9ca0e7905c
commit
77f604a928
6 changed files with 33 additions and 20 deletions
|
@ -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,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue