Example #1
0
func (c *Commit) CommitsBefore() (*list.List, error) {
	hist := history.New(c.repo.repo)
	result, err := hist.WalkHistory(sha2oidp(c.ID), nil)
	if err != nil {
		return nil, err
	}

	return c.repo.raw2commitList(result)
}
Example #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)
}
Example #3
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)
}
Example #4
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 #5
0
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)
}
Example #6
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
}
Example #7
0
func (c *Commit) SearchCommits(keyword string) (*list.List, error) {
	searcher, err := history.MakeHistorySearcher(keyword)
	if err != nil {
		return nil, err
	}

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

	return c.repo.raw2commitList(result)
}
Example #8
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))
}