mirror of
https://github.com/gogs/gogs.git
synced 2025-12-22 00:00:07 +01:00
commits: able to specify pageSize dynamically (#3965)
Usage: <url>?page={page}&pageSize={pageSize}
Also avoid/removed getting total commits count for pagination,
users are only allowed navigation by 'newer' and 'older'.
This commit is contained in:
24
vendor/github.com/gogits/git-module/repo_commit.go
generated
vendored
24
vendor/github.com/gogits/git-module/repo_commit.go
generated
vendored
@@ -200,17 +200,21 @@ func (repo *Repository) GetCommitByPath(relpath string) (*Commit, error) {
|
||||
return commits.Front().Value.(*Commit), nil
|
||||
}
|
||||
|
||||
var CommitsRangeSize = 50
|
||||
|
||||
func (repo *Repository) commitsByRange(id sha1, page int) (*list.List, error) {
|
||||
stdout, err := NewCommand("log", id.String(), "--skip="+strconv.Itoa((page-1)*CommitsRangeSize),
|
||||
"--max-count="+strconv.Itoa(CommitsRangeSize), _PRETTY_LOG_FORMAT).RunInDirBytes(repo.Path)
|
||||
func (repo *Repository) CommitsByRangeSize(revision string, page, size int) (*list.List, error) {
|
||||
stdout, err := NewCommand("log", revision, "--skip="+strconv.Itoa((page-1)*size),
|
||||
"--max-count="+strconv.Itoa(size), _PRETTY_LOG_FORMAT).RunInDirBytes(repo.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return repo.parsePrettyFormatLogToList(stdout)
|
||||
}
|
||||
|
||||
const DEFAULT_COMMITS_PAGE_SIZE = 50
|
||||
|
||||
func (repo *Repository) CommitsByRange(revision string, page int) (*list.List, error) {
|
||||
return repo.CommitsByRangeSize(revision, page, DEFAULT_COMMITS_PAGE_SIZE)
|
||||
}
|
||||
|
||||
func (repo *Repository) searchCommits(id sha1, keyword string) (*list.List, error) {
|
||||
stdout, err := NewCommand("log", id.String(), "-100", "-i", "--grep="+keyword, _PRETTY_LOG_FORMAT).RunInDirBytes(repo.Path)
|
||||
if err != nil {
|
||||
@@ -231,15 +235,19 @@ func (repo *Repository) FileCommitsCount(revision, file string) (int64, error) {
|
||||
return commitsCount(repo.Path, revision, file)
|
||||
}
|
||||
|
||||
func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (*list.List, error) {
|
||||
stdout, err := NewCommand("log", revision, "--skip="+strconv.Itoa((page-1)*50),
|
||||
"--max-count="+strconv.Itoa(CommitsRangeSize), _PRETTY_LOG_FORMAT, "--", file).RunInDirBytes(repo.Path)
|
||||
func (repo *Repository) CommitsByFileAndRangeSize(revision, file string, page, size int) (*list.List, error) {
|
||||
stdout, err := NewCommand("log", revision, "--skip="+strconv.Itoa((page-1)*size),
|
||||
"--max-count="+strconv.Itoa(size), _PRETTY_LOG_FORMAT, "--", file).RunInDirBytes(repo.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return repo.parsePrettyFormatLogToList(stdout)
|
||||
}
|
||||
|
||||
func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (*list.List, error) {
|
||||
return repo.CommitsByFileAndRangeSize(revision, file, page, DEFAULT_COMMITS_PAGE_SIZE)
|
||||
}
|
||||
|
||||
func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (int, error) {
|
||||
stdout, err := NewCommand("diff", "--name-only", startCommitID+"..."+endCommitID).RunInDir(repo.Path)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user