1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-23 02:38:35 +00:00

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
This commit is contained in:
jaqra
2019-11-07 21:09:51 +03:00
committed by Lauris BH
parent 1f90147f39
commit 065bbddab9
3 changed files with 22 additions and 1 deletions

View File

@@ -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)

View File

@@ -46,6 +46,11 @@ type GPGSettings struct {
const prettyLogFormat = `--pretty=format:%H`
// GetAllCommitsCount returns count of all commits in repository
func (repo *Repository) GetAllCommitsCount() (int64, error) {
return AllCommitsCount(repo.Path)
}
func (repo *Repository) parsePrettyFormatLogToList(logs []byte) (*list.List, error) {
l := list.New()
if len(logs) == 0 {