aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/gogits/git-module/repo_commit.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2017-02-18 18:37:47 -0500
committerUnknwon <u@gogs.io>2017-02-18 18:37:47 -0500
commitc69900325d3b2d5eb7584512547fdc567bf6df91 (patch)
tree3e276a812d99eff360afe4ed614ad28cfad2c5c9 /vendor/github.com/gogits/git-module/repo_commit.go
parent685737b8168ea4cf23410d5adf83fcb0ed581467 (diff)
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'.
Diffstat (limited to 'vendor/github.com/gogits/git-module/repo_commit.go')
-rw-r--r--vendor/github.com/gogits/git-module/repo_commit.go24
1 files changed, 16 insertions, 8 deletions
diff --git a/vendor/github.com/gogits/git-module/repo_commit.go b/vendor/github.com/gogits/git-module/repo_commit.go
index 34a81a4b..6424c5a6 100644
--- a/vendor/github.com/gogits/git-module/repo_commit.go
+++ b/vendor/github.com/gogits/git-module/repo_commit.go
@@ -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 {