Skip to content

Instantly share code, notes, and snippets.

@shiftkey
Created June 4, 2014 14:35
Show Gist options
  • Save shiftkey/8f42142a52338950df08 to your computer and use it in GitHub Desktop.
Save shiftkey/8f42142a52338950df08 to your computer and use it in GitHub Desktop.
octokit.net list off contributors who have had a pull requests merged into a repository
var client = new GitHubClient(new Octokit.ProductHeaderValue("NDC-Oslo"))
{
Credentials = new Credentials("some-username", "some-password")
};
// find all merged PRs
var filter = new PullRequestRequest() { State = ItemState.Closed };
var pullRequests = await client.Repository.PullRequest.GetForRepository("octokit", "octokit.net", filter);
Console.WriteLine("Pull Requests: " + pullRequests.Count);
var contributors = pullRequests.Where(x => x.MergedAt.HasValue)
.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