Last active
August 29, 2015 14:04
-
-
Save glennblock/4631cb9c90e033de948b to your computer and use it in GitHub Desktop.
Get contributors for a release via Oktokit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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