mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 00:20:25 +08: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:
		@@ -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,
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user