Exemple #1
0
func (c *Commit) CommitsByRange(page int) (*list.List, error) {
	pager := history.MakePager(c.repo.repo, nil, (page-1)*CommitsRangeSize, CommitsRangeSize)
	hist := history.New(c.repo.repo)
	result, err := hist.WalkHistory(sha2oidp(c.ID), pager)
	if err != nil {
		return nil, err
	}

	return c.repo.raw2commitList(result)
}
Exemple #2
0
func (c *Commit) CommitsBeforeLimit(num int) (*list.List, error) {
	pager := history.MakePager(c.repo.repo, nil, 0, num)
	hist := history.New(c.repo.repo)
	result, err := hist.WalkHistory(sha2oidp(c.ID), pager)
	if err != nil {
		return nil, err
	}

	return c.repo.raw2commitList(result)
}
func (repo *Repository) commitsByFileAndRange(commit *Commit, file string, page int) (*list.List, error) {
	pathCb := history.MakePathChecker(commit.repo.repo, file)
	cmp := history.MakePathComparator(commit.repo.repo, file)
	pager := history.MakePager(commit.repo.repo, pathCb, (page-1)*CommitsRangeSize, CommitsRangeSize)

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

	return repo.raw2commitList(result)
}
Exemple #4
0
// GetCommitByPath return the commit of relative path object.
func (c *Commit) GetCommitByPath(relpath string) (*Commit, error) {
	pathCb := history.MakePathChecker(c.repo.repo, relpath)
	pager := history.MakePager(c.repo.repo, pathCb, 0, 1)
	cmp := history.MakePathComparator(c.repo.repo, relpath)

	hist := history.New(c.repo.repo)
	result, err := hist.WalkFilteredHistory(sha2oidp(c.ID), pager, cmp)
	if err != nil {
		return nil, err
	}

	if result.Len() == 0 {
		// no entries
		return nil, nil
	}

	return raw2commit(c.repo, result.Front().Value.(*rawgit.Commit))
}