diff options
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) |