forked from Gitlink/gitea-1156
fixed: file_commits分页大小参数无效
This commit is contained in:
parent
0c2be1c244
commit
a813f92d31
|
@ -193,7 +193,7 @@ func (c *Commit) CommitsByRange(page, pageSize int) (*list.List, error) {
|
|||
|
||||
// CommitsByFileAndRange returns the specific page page commits before current revision and file, every page's number default by CommitsRangeSize
|
||||
func (c *Commit) CommitsByFileAndRange(file string, page, pageSize int) (*list.List, error) {
|
||||
return c.repo.CommitsByFileAndRange(c.ID.String(), file, page)
|
||||
return c.repo.CommitsByFileAndRange(c.ID.String(), file, page, pageSize)
|
||||
}
|
||||
|
||||
// CommitsBefore returns all the commits before current revision
|
||||
|
|
|
@ -214,7 +214,7 @@ func (repo *Repository) GetFirstAndLastCommitByPath(revision, relpath string) (*
|
|||
}
|
||||
|
||||
// CommitsByFileAndRange return the commits according revision file and the page
|
||||
func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (*list.List, error) {
|
||||
func (repo *Repository) CommitsByFileAndRange(revision, file string, page int, pageSize int) (*list.List, error) {
|
||||
skip := (page - 1) * setting.Git.CommitsRangeSize
|
||||
|
||||
stdoutReader, stdoutWriter := io.Pipe()
|
||||
|
@ -223,9 +223,12 @@ func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (
|
|||
_ = stdoutWriter.Close()
|
||||
}()
|
||||
go func() {
|
||||
if pageSize <= 0 {
|
||||
pageSize = setting.Git.CommitsRangeSize
|
||||
}
|
||||
stderr := strings.Builder{}
|
||||
err := NewCommand("log", revision, "--follow",
|
||||
"--max-count="+strconv.Itoa(setting.Git.CommitsRangeSize*page),
|
||||
"--max-count="+strconv.Itoa(pageSize*page),
|
||||
prettyLogFormat, "--", file).
|
||||
RunInDirPipeline(repo.Path, stdoutWriter, &stderr)
|
||||
if err != nil {
|
||||
|
|
|
@ -230,11 +230,12 @@ func FileHistory(ctx *context.Context) {
|
|||
}
|
||||
|
||||
page := ctx.QueryInt("page")
|
||||
limit := ctx.QueryInt("limit")
|
||||
if page <= 1 {
|
||||
page = 1
|
||||
}
|
||||
|
||||
commits, err := ctx.Repo.GitRepo.CommitsByFileAndRange(branchName, fileName, page)
|
||||
commits, err := ctx.Repo.GitRepo.CommitsByFileAndRange(branchName, fileName, page, limit)
|
||||
if err != nil {
|
||||
ctx.ServerError("CommitsByFileAndRange", err)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue