summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/context/repo.go2
-rw-r--r--modules/git/repo_tag_gogit.go13
-rw-r--r--modules/git/repo_tag_nogogit.go5
-rw-r--r--modules/repository/repo.go2
-rw-r--r--routers/web/repo/compare.go6
-rw-r--r--routers/web/repo/release.go25
6 files changed, 33 insertions, 20 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go
index df71638350..89ff890cc3 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -547,7 +547,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
return
}
- tags, err := ctx.Repo.GitRepo.GetTags()
+ tags, err := ctx.Repo.GitRepo.GetTags(0, 0)
if err != nil {
ctx.ServerError("GetTags", err)
return
diff --git a/modules/git/repo_tag_gogit.go b/modules/git/repo_tag_gogit.go
index 3022fe96f7..ff8a6d53ee 100644
--- a/modules/git/repo_tag_gogit.go
+++ b/modules/git/repo_tag_gogit.go
@@ -21,7 +21,8 @@ func (repo *Repository) IsTagExist(name string) bool {
}
// GetTags returns all tags of the repository.
-func (repo *Repository) GetTags() ([]string, error) {
+// returning at most limit tags, or all if limit is 0.
+func (repo *Repository) GetTags(skip, limit int) ([]string, error) {
var tagNames []string
tags, err := repo.gogitRepo.Tags()
@@ -40,5 +41,15 @@ func (repo *Repository) GetTags() ([]string, error) {
tagNames[i], tagNames[j] = tagNames[j], tagNames[i]
}
+ // since we have to reverse order we can paginate only afterwards
+ if len(tagNames) < skip {
+ tagNames = []string{}
+ } else {
+ tagNames = tagNames[skip:]
+ }
+ if limit != 0 && len(tagNames) > limit {
+ tagNames = tagNames[:limit]
+ }
+
return tagNames, nil
}
diff --git a/modules/git/repo_tag_nogogit.go b/modules/git/repo_tag_nogogit.go
index 0170f0cc76..172b6fd66c 100644
--- a/modules/git/repo_tag_nogogit.go
+++ b/modules/git/repo_tag_nogogit.go
@@ -18,7 +18,8 @@ func (repo *Repository) IsTagExist(name string) bool {
}
// GetTags returns all tags of the repository.
-func (repo *Repository) GetTags() (tags []string, err error) {
- tags, _, err = callShowRef(repo.Path, TagPrefix, "--tags", 0, 0)
+// returning at most limit tags, or all if limit is 0.
+func (repo *Repository) GetTags(skip, limit int) (tags []string, err error) {
+ tags, _, err = callShowRef(repo.Path, TagPrefix, "--tags", skip, limit)
return
}
diff --git a/modules/repository/repo.go b/modules/repository/repo.go
index 6b87039775..00413549ee 100644
--- a/modules/repository/repo.go
+++ b/modules/repository/repo.go
@@ -250,7 +250,7 @@ func SyncReleasesWithTags(repo *models.Repository, gitRepo *git.Repository) erro
}
}
}
- tags, err := gitRepo.GetTags()
+ tags, err := gitRepo.GetTags(0, 0)
if err != nil {
return fmt.Errorf("GetTags: %v", err)
}
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,
}