diff options
author | jaqra <48099350+jaqra@users.noreply.github.com> | 2019-11-07 21:09:51 +0300 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-11-07 20:09:51 +0200 |
commit | 065bbddab91791666ef1d0e10765f58595094a1e (patch) | |
tree | 2c6aa684fc738d5d0111176ad42480bb5bc9fb1e /modules/git/commit.go | |
parent | 1f90147f3942065e2a7f564e8a3c97d23d41e6c0 (diff) | |
download | gitea-065bbddab91791666ef1d0e10765f58595094a1e.tar.gz gitea-065bbddab91791666ef1d0e10765f58595094a1e.zip |
Fix count for commit graph last page (#8843)
* Fix count for commit graph last page
* Remove used once variable
* Move func to model
* capitalize method name
* fix error message
Diffstat (limited to 'modules/git/commit.go')
-rw-r--r-- | modules/git/commit.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/git/commit.go b/modules/git/commit.go index 45b943e79e..ce55dd55f6 100644 --- a/modules/git/commit.go +++ b/modules/git/commit.go @@ -248,6 +248,16 @@ func CommitChanges(repoPath string, opts CommitChangesOptions) error { return err } +// AllCommitsCount returns count of all commits in repository +func AllCommitsCount(repoPath string) (int64, error) { + stdout, err := NewCommand("rev-list", "--all", "--count").RunInDir(repoPath) + if err != nil { + return 0, err + } + + return strconv.ParseInt(strings.TrimSpace(stdout), 10, 64) +} + func commitsCount(repoPath, revision, relpath string) (int64, error) { cmd := NewCommand("rev-list", "--count") cmd.AddArguments(revision) |