* Fix count for commit graph last page * Remove used once variable * Move func to model * capitalize method name * fix error messagetags/v1.11.0-rc1
return err | 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) { | func commitsCount(repoPath, revision, relpath string) (int64, error) { | ||||
cmd := NewCommand("rev-list", "--count") | cmd := NewCommand("rev-list", "--count") | ||||
cmd.AddArguments(revision) | cmd.AddArguments(revision) |
const prettyLogFormat = `--pretty=format:%H` | 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) { | func (repo *Repository) parsePrettyFormatLogToList(logs []byte) (*list.List, error) { | ||||
l := list.New() | l := list.New() | ||||
if len(logs) == 0 { | if len(logs) == 0 { |
return | return | ||||
} | } | ||||
allCommitsCount, err := ctx.Repo.GitRepo.GetAllCommitsCount() | |||||
if err != nil { | |||||
ctx.ServerError("GetAllCommitsCount", err) | |||||
return | |||||
} | |||||
page := ctx.QueryInt("page") | page := ctx.QueryInt("page") | ||||
graph, err := models.GetCommitGraph(ctx.Repo.GitRepo, page) | graph, err := models.GetCommitGraph(ctx.Repo.GitRepo, page) | ||||
ctx.Data["CommitCount"] = commitsCount | ctx.Data["CommitCount"] = commitsCount | ||||
ctx.Data["Branch"] = ctx.Repo.BranchName | ctx.Data["Branch"] = ctx.Repo.BranchName | ||||
ctx.Data["RequireGitGraph"] = true | ctx.Data["RequireGitGraph"] = true | ||||
ctx.Data["Page"] = context.NewPagination(int(commitsCount), setting.UI.GraphMaxCommitNum, page, 5) | |||||
ctx.Data["Page"] = context.NewPagination(int(allCommitsCount), setting.UI.GraphMaxCommitNum, page, 5) | |||||
ctx.HTML(200, tplGraph) | ctx.HTML(200, tplGraph) | ||||
} | } | ||||