Skip to content

Instantly share code, notes, and snippets.

@glennblock
Last active August 29, 2015 14:04
Show Gist options
  • Save glennblock/4631cb9c90e033de948b to your computer and use it in GitHub Desktop.
Save glennblock/4631cb9c90e033de948b to your computer and use it in GitHub Desktop.
Get contributors for a release via Oktokit
using Octokit;
var client = new GitHubClient(new ProductHeaderValue("scriptcs"))
{
Credentials = new Credentials(user, password)
};
// find all merged PRs
var filter = new PullRequestRequest() { State = ItemState.Closed };
var pullRequests = client.Repository.PullRequest.GetForRepository("scriptcs", "scriptcs", filter).Result;
Console.WriteLine("Pull Requests: " + pullRequests.Count);
var startDate = new DateTimeOffset(DateTime.Parse("01/21/2014"));
var contributors = pullRequests.Where(x => x.MergedAt.HasValue && DateTimeOffset.Compare(x.MergedAt.Value, startDate) > 0)
.GroupBy(x => x.User.Login)
.Select(x => new { Key = x.Key, Count = x.Count() })
.OrderByDescending(x => x.Count);
Console.WriteLine("Contributors: " + contributors.Count());
Console.WriteLine();
foreach(var contributor in contributors)
{
Console.WriteLine("{0} has {1} merged PRs", contributor.Key, contributor.Count);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment