PowerShell/demos/rest/rest.ps1

46 lines
1 KiB
PowerShell
Raw Normal View History

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
2016-08-18 03:01:15 +02:00
#-----------------
function Get-Issue
2016-08-18 03:01:15 +02:00
{
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]
2016-08-18 03:01:15 +02:00
}
}
}
}
$issues = Get-Issue -UserName lzybkr -Repo PSReadline
2016-08-18 03:01:15 +02:00
$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
}
}