-
Notifications
You must be signed in to change notification settings - Fork 7.2k
/
rest.ps1
45 lines (36 loc) · 1.03 KB
/
rest.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#-----------------
function Get-Issue
{
param([string]$UserName,
[string]$Repo,
[ValidateRange(1,100)][int]$PerPage = 100)
$body = @{
per_page = $PerPage
}
$uri = "https://api.github.com/repos/$UserName/$Repo/issues"
while ($uri)
{
$response = Invoke-WebRequest -Uri $uri -Body $body
$response.Content | ConvertFrom-Json | Write-Output
$uri = $null
foreach ($link in $response.Headers.Link -split ',')
{
if ($link -match '\s*<(.*)>;\s+rel="next"')
{
$uri = $Matches[1]
}
}
}
}
$issues = Get-Issue -UserName lzybkr -Repo PSReadline
$issues.Count
$issues | Sort-Object -Descending comments | Select-Object -First 15 | ft number,comments,title
foreach ($issue in $issues)
{
if ($issue.labels.name -contains 'bug' -and $issue.labels.name -contains 'vi mode')
{
"{0} is a vi mode bug" -f $issue.url
}
}