diff options
author | Unknwon <u@gogs.io> | 2017-02-18 18:37:47 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-02-18 18:37:47 -0500 |
commit | c69900325d3b2d5eb7584512547fdc567bf6df91 (patch) | |
tree | 3e276a812d99eff360afe4ed614ad28cfad2c5c9 /vendor | |
parent | 685737b8168ea4cf23410d5adf83fcb0ed581467 (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')
-rw-r--r-- | vendor/github.com/Unknwon/i18n/Makefile | 12 | ||||
-rw-r--r-- | vendor/github.com/Unknwon/i18n/i18n.go | 27 | ||||
-rw-r--r-- | vendor/github.com/gogits/git-module/commit.go | 6 | ||||
-rw-r--r-- | vendor/github.com/gogits/git-module/git.go | 2 | ||||
-rw-r--r-- | vendor/github.com/gogits/git-module/repo_commit.go | 24 | ||||
-rw-r--r-- | vendor/vendor.json | 12 |
6 files changed, 55 insertions, 28 deletions
diff --git a/vendor/github.com/Unknwon/i18n/Makefile b/vendor/github.com/Unknwon/i18n/Makefile new file mode 100644 index 00000000..8ff1ac43 --- /dev/null +++ b/vendor/github.com/Unknwon/i18n/Makefile @@ -0,0 +1,12 @@ +.PHONY: build test bench vet + +build: vet bench + +test: + go test -v -cover + +bench: + go test -v -cover -test.bench=. -test.benchmem + +vet: + go vet
\ No newline at end of file diff --git a/vendor/github.com/Unknwon/i18n/i18n.go b/vendor/github.com/Unknwon/i18n/i18n.go index 962fbcf0..0e7e919a 100644 --- a/vendor/github.com/Unknwon/i18n/i18n.go +++ b/vendor/github.com/Unknwon/i18n/i18n.go @@ -194,10 +194,11 @@ func (l Locale) Index() int { // Tr translates content to target language. func Tr(lang, format string, args ...interface{}) string { var section string - parts := strings.SplitN(format, ".", 2) - if len(parts) == 2 { - section = parts[0] - format = parts[1] + + idx := strings.IndexByte(format, '.') + if idx > 0 { + section = format[:idx] + format = format[idx+1:] } value, ok := locales.Get(lang, section, format) @@ -208,15 +209,17 @@ func Tr(lang, format string, args ...interface{}) string { if len(args) > 0 { params := make([]interface{}, 0, len(args)) for _, arg := range args { - if arg != nil { - val := reflect.ValueOf(arg) - if val.Kind() == reflect.Slice { - for i := 0; i < val.Len(); i++ { - params = append(params, val.Index(i).Interface()) - } - } else { - params = append(params, arg) + if arg == nil { + continue + } + + val := reflect.ValueOf(arg) + if val.Kind() == reflect.Slice { + for i := 0; i < val.Len(); i++ { + params = append(params, val.Index(i).Interface()) } + } else { + params = append(params, arg) } } return fmt.Sprintf(format, params...) diff --git a/vendor/github.com/gogits/git-module/commit.go b/vendor/github.com/gogits/git-module/commit.go index d9a7b582..b68a6b97 100644 --- a/vendor/github.com/gogits/git-module/commit.go +++ b/vendor/github.com/gogits/git-module/commit.go @@ -170,8 +170,12 @@ func (c *Commit) CommitsCount() (int64, error) { return CommitsCount(c.repo.Path, c.ID.String()) } +func (c *Commit) CommitsByRangeSize(page, size int) (*list.List, error) { + return c.repo.CommitsByRangeSize(c.ID.String(), page, size) +} + func (c *Commit) CommitsByRange(page int) (*list.List, error) { - return c.repo.commitsByRange(c.ID, page) + return c.repo.CommitsByRange(c.ID.String(), page) } func (c *Commit) CommitsBefore() (*list.List, error) { diff --git a/vendor/github.com/gogits/git-module/git.go b/vendor/github.com/gogits/git-module/git.go index a01f4e22..eee4b1b5 100644 --- a/vendor/github.com/gogits/git-module/git.go +++ b/vendor/github.com/gogits/git-module/git.go @@ -10,7 +10,7 @@ import ( "time" ) -const _VERSION = "0.4.10" +const _VERSION = "0.4.11" func Version() string { return _VERSION 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 { diff --git a/vendor/vendor.json b/vendor/vendor.json index ce6746cb..298dac14 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -21,10 +21,10 @@ "revisionTime": "2017-02-13T07:20:14Z" }, { - "checksumSHA1": "gSAaJ38R4iqG2CEsZe/ftOs3V9w=", + "checksumSHA1": "qbYhQkK6nb2oZ9OOyyuQpWD9fXY=", "path": "github.com/Unknwon/i18n", - "revision": "39d6f2727e0698b1021ceb6a77c1801aa92e7d5d", - "revisionTime": "2016-06-03T08:28:25Z" + "revision": "e0eb0cef13c5eadc03d6993f3069c72e566004b7", + "revisionTime": "2017-02-18T21:29:01Z" }, { "checksumSHA1": "VI3Bz1L335gsrP1ZF0v3f+WWy3M=", @@ -159,10 +159,10 @@ "revisionTime": "2016-08-10T03:50:02Z" }, { - "checksumSHA1": "5SLknh130FbmnSNWkf6LtVFqdMI=", + "checksumSHA1": "mR45j8svu6CZu81VqN+lfgpCVjA=", "path": "github.com/gogits/git-module", - "revision": "7c2ab580a5b25e8b045139a44635258ceef64ace", - "revisionTime": "2017-02-17T22:39:06Z" + "revision": "fa2ace85ecb113f89f6862d8a6e3075a7aa425b9", + "revisionTime": "2017-02-18T23:35:37Z" }, { "checksumSHA1": "xvG+RgJODQqlmdAkHUQK2TyLR88=", |