From bd5d1341d43a94ac6b5f646eb9d995a48ba844e1 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Mon, 23 Dec 2024 15:07:12 +0800 Subject: Fix commit range paging (#32944) --- modules/git/repo_commit.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'modules/git/repo_commit.go') diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go index 9ffadb833d..647894bb21 100644 --- a/modules/git/repo_commit.go +++ b/modules/git/repo_commit.go @@ -216,8 +216,6 @@ type CommitsByFileAndRangeOptions struct { // CommitsByFileAndRange return the commits according revision file and the page func (repo *Repository) CommitsByFileAndRange(opts CommitsByFileAndRangeOptions) ([]*Commit, error) { - skip := (opts.Page - 1) * setting.Git.CommitsRangeSize - stdoutReader, stdoutWriter := io.Pipe() defer func() { _ = stdoutReader.Close() @@ -226,8 +224,8 @@ func (repo *Repository) CommitsByFileAndRange(opts CommitsByFileAndRangeOptions) go func() { stderr := strings.Builder{} gitCmd := NewCommand(repo.Ctx, "rev-list"). - AddOptionFormat("--max-count=%d", setting.Git.CommitsRangeSize*opts.Page). - AddOptionFormat("--skip=%d", skip) + AddOptionFormat("--max-count=%d", setting.Git.CommitsRangeSize). + AddOptionFormat("--skip=%d", (opts.Page-1)*setting.Git.CommitsRangeSize) gitCmd.AddDynamicArguments(opts.Revision) if opts.Not != "" { -- cgit v1.2.3