Created
October 24, 2016 16:29
-
-
Save afscrome/70739290991a328b5ab9935575b58e8d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#This script calculates how many PRs each person merged | |
param( | |
[Parameter(Mandatory=$true)] | |
[string]$PersonalAccessToken, | |
[Parameter(Mandatory=$true)] | |
[string]$OrgOrUser, | |
[Parameter(Mandatory=$true)] | |
[string]$RepoName | |
) | |
$base64Token = [Convert]::ToBase64String([char[]]$PersonalAccessToken) | |
$Headers = @{ | |
Authorization ="Basic $Base64Token" | |
} | |
$url = "https://api.github.com/repos/$OrgOrUser/$RepoName/pulls?state=closed" | |
$results = @() | |
while($true) { | |
$response = Invoke-WebRequest -Headers $Headers -Uri $url -UseBasicParsing | |
$results += $response.Content | ConvertFrom-Json | |
$match = [regex]::Match($response.Headers['Link'], '<([^>]+)>;\s*rel="next"') | |
if(-not $match.Success){ | |
break | |
} | |
$url = $match.Groups[1].Value | |
} | |
$prs = $results._links.self.href |% { Invoke-RestMethod -Headers $Headers -Uri $_ } | |
$prs | select -ExpandProperty merged_by | group login |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment