diff options
Diffstat (limited to 'routers/repo')
-rw-r--r-- | routers/repo/commit.go | 7 | ||||
-rw-r--r-- | routers/repo/issue.go | 14 | ||||
-rw-r--r-- | routers/repo/issue_label.go | 2 | ||||
-rw-r--r-- | routers/repo/release.go | 25 | ||||
-rw-r--r-- | routers/repo/setting.go | 6 | ||||
-rw-r--r-- | routers/repo/view.go | 6 | ||||
-rw-r--r-- | routers/repo/webhook.go | 2 |
7 files changed, 36 insertions, 26 deletions
diff --git a/routers/repo/commit.go b/routers/repo/commit.go index e581d39526..cb9727fccc 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -58,8 +58,13 @@ func Commits(ctx *context.Context) { page = 1 } + pageSize := ctx.QueryInt("limit") + if pageSize <= 0 { + pageSize = git.CommitsRangeSize + } + // Both `git log branchName` and `git log commitId` work. - commits, err := ctx.Repo.Commit.CommitsByRange(page) + commits, err := ctx.Repo.Commit.CommitsByRange(page, pageSize) if err != nil { ctx.ServerError("CommitsByRange", err) return diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 49481e7e2e..fdade2795d 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -195,13 +195,15 @@ func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalB issues = []*models.Issue{} } else { issues, err = models.Issues(&models.IssuesOptions{ + ListOptions: models.ListOptions{ + Page: pager.Paginater.Current(), + PageSize: setting.UI.IssuePagingNum, + }, RepoIDs: []int64{repo.ID}, AssigneeID: assigneeID, PosterID: posterID, MentionedID: mentionedID, MilestoneID: milestoneID, - Page: pager.Paginater.Current(), - PageSize: setting.UI.IssuePagingNum, IsClosed: util.OptionalBoolOf(isShowClosed), IsPull: isPullOption, LabelIDs: labelIDs, @@ -246,7 +248,7 @@ func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalB return } - labels, err := models.GetLabelsByRepoID(repo.ID, "") + labels, err := models.GetLabelsByRepoID(repo.ID, "", models.ListOptions{}) if err != nil { ctx.ServerError("GetLabelsByRepoID", err) return @@ -309,7 +311,7 @@ func Issues(ctx *context.Context) { var err error // Get milestones. - ctx.Data["Milestones"], err = models.GetMilestonesByRepoID(ctx.Repo.Repository.ID, api.StateType(ctx.Query("state"))) + ctx.Data["Milestones"], err = models.GetMilestonesByRepoID(ctx.Repo.Repository.ID, api.StateType(ctx.Query("state")), models.ListOptions{}) if err != nil { ctx.ServerError("GetAllRepoMilestones", err) return @@ -347,7 +349,7 @@ func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository, isPull boo return nil } - labels, err := models.GetLabelsByRepoID(repo.ID, "") + labels, err := models.GetLabelsByRepoID(repo.ID, "", models.ListOptions{}) if err != nil { ctx.ServerError("GetLabelsByRepoID", err) return nil @@ -733,7 +735,7 @@ func ViewIssue(ctx *context.Context) { for i := range issue.Labels { labelIDMark[issue.Labels[i].ID] = true } - labels, err := models.GetLabelsByRepoID(repo.ID, "") + labels, err := models.GetLabelsByRepoID(repo.ID, "", models.ListOptions{}) if err != nil { ctx.ServerError("GetLabelsByRepoID", err) return diff --git a/routers/repo/issue_label.go b/routers/repo/issue_label.go index 98f2dded31..e61fcbe5cb 100644 --- a/routers/repo/issue_label.go +++ b/routers/repo/issue_label.go @@ -50,7 +50,7 @@ func InitializeLabels(ctx *context.Context, form auth.InitializeLabelsForm) { // RetrieveLabels find all the labels of a repository func RetrieveLabels(ctx *context.Context) { - labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Query("sort")) + labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Query("sort"), models.ListOptions{}) if err != nil { ctx.ServerError("RetrieveLabels.GetLabels", err) return diff --git a/routers/repo/release.go b/routers/repo/release.go index 0ab8450bd5..5454195181 100644 --- a/routers/repo/release.go +++ b/routers/repo/release.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/modules/auth" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/convert" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/setting" @@ -56,24 +57,26 @@ func Releases(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.release.releases") ctx.Data["PageIsReleaseList"] = true - page := ctx.QueryInt("page") - if page <= 1 { - page = 1 - } - limit := ctx.QueryInt("limit") - if limit <= 0 { - limit = 10 - } - writeAccess := ctx.Repo.CanWrite(models.UnitTypeReleases) ctx.Data["CanCreateRelease"] = writeAccess && !ctx.Repo.Repository.IsArchived opts := models.FindReleasesOptions{ + ListOptions: models.ListOptions{ + Page: ctx.QueryInt("page"), + PageSize: convert.ToCorrectPageSize(ctx.QueryInt("limit")), + }, IncludeDrafts: writeAccess, IncludeTags: true, } - releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, opts, page, limit) + if opts.ListOptions.Page <= 1 { + opts.ListOptions.Page = 1 + } + if opts.ListOptions.PageSize <= 0 { + opts.ListOptions.Page = 10 + } + + releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, opts) if err != nil { ctx.ServerError("GetReleasesByRepoID", err) return @@ -121,7 +124,7 @@ func Releases(ctx *context.Context) { ctx.Data["Releases"] = releases - pager := context.NewPagination(int(count), limit, page, 5) + pager := context.NewPagination(int(count), opts.PageSize, opts.Page, 5) pager.SetDefaultParams(ctx) ctx.Data["Page"] = pager diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 6ad0b4a967..22699f9e8d 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -486,7 +486,7 @@ func Collaboration(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings") ctx.Data["PageIsSettingsCollaboration"] = true - users, err := ctx.Repo.Repository.GetCollaborators() + users, err := ctx.Repo.Repository.GetCollaborators(models.ListOptions{}) if err != nil { ctx.ServerError("GetCollaborators", err) return @@ -738,7 +738,7 @@ func DeployKeys(ctx *context.Context) { ctx.Data["PageIsSettingsKeys"] = true ctx.Data["DisableSSH"] = setting.SSH.Disabled - keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID) + keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID, models.ListOptions{}) if err != nil { ctx.ServerError("ListDeployKeys", err) return @@ -753,7 +753,7 @@ func DeployKeysPost(ctx *context.Context, form auth.AddKeyForm) { ctx.Data["Title"] = ctx.Tr("repo.settings.deploy_keys") ctx.Data["PageIsSettingsKeys"] = true - keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID) + keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID, models.ListOptions{}) if err != nil { ctx.ServerError("ListDeployKeys", err) return diff --git a/routers/repo/view.go b/routers/repo/view.go index 8730523d89..3fbff007e1 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -522,7 +522,7 @@ func renderCode(ctx *context.Context) { } // RenderUserCards render a page show users according the input templaet -func RenderUserCards(ctx *context.Context, total int, getter func(page int) ([]*models.User, error), tpl base.TplName) { +func RenderUserCards(ctx *context.Context, total int, getter func(opts models.ListOptions) ([]*models.User, error), tpl base.TplName) { page := ctx.QueryInt("page") if page <= 0 { page = 1 @@ -530,7 +530,7 @@ func RenderUserCards(ctx *context.Context, total int, getter func(page int) ([]* pager := context.NewPagination(total, models.ItemsPerPage, page, 5) ctx.Data["Page"] = pager - items, err := getter(pager.Paginater.Current()) + items, err := getter(models.ListOptions{Page: pager.Paginater.Current()}) if err != nil { ctx.ServerError("getter", err) return @@ -561,7 +561,7 @@ func Stars(ctx *context.Context) { func Forks(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repos.forks") - forks, err := ctx.Repo.Repository.GetForks() + forks, err := ctx.Repo.Repository.GetForks(models.ListOptions{}) if err != nil { ctx.ServerError("GetForks", err) return diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go index 9ae15882c1..049ce0aedf 100644 --- a/routers/repo/webhook.go +++ b/routers/repo/webhook.go @@ -38,7 +38,7 @@ func Webhooks(ctx *context.Context) { ctx.Data["BaseLink"] = ctx.Repo.RepoLink + "/settings/hooks" ctx.Data["Description"] = ctx.Tr("repo.settings.hooks_desc", "https://docs.gitea.io/en-us/webhooks/") - ws, err := models.GetWebhooksByRepoID(ctx.Repo.Repository.ID) + ws, err := models.GetWebhooksByRepoID(ctx.Repo.Repository.ID, models.ListOptions{}) if err != nil { ctx.ServerError("GetWebhooksByRepoID", err) return |