I’m doing a loop:
using LibGit2Sharp;
var filter = new Filter { Since = repo.Refs };
IEnumerable<Commit> commits = repo.Commits.QueryBy(filter);
foreach (Commit commit in commits)
{
//Do stuff...
}
It works fine, but is there a way I can limit the number of results? For example, I’d like to get the newest 100 commits, and forget about the older ones.
What about using LINQ’s Take
Checking the code of CommitCollection it seems it will really just return 100 commits (so it don’t lookup all then take 100).
And you can set the required sort order with the
Filter.SortByproperty.