Example #1
0
func (c *Commit) CommitsCount() (int64, error) {
	counter, result := history.MakeCounter(nil)

	hist := history.New(c.repo.repo)
	_, err := hist.WalkHistory(sha2oidp(c.ID), counter)
	if err != nil {
		return 0, err
	}

	return int64(result()), nil
}
Example #2
0
func (repo *Repository) fileCommitsCount(commit *Commit, file string) (int64, error) {
	pathCb := history.MakePathChecker(commit.repo.repo, file)
	cmp := history.MakePathComparator(commit.repo.repo, file)
	counter, result := history.MakeCounter(pathCb)

	hist := history.New(commit.repo.repo)
	_, err := hist.WalkFilteredHistory(sha2oidp(commit.ID), counter, cmp)
	if err != nil {
		return 0, err
	}

	return int64(result()), nil
}