From 1a808d6356ed26d6cfdd058353ae2dd7888fe797 Mon Sep 17 00:00:00 2001 From: MaksimZhukov Date: Thu, 30 Apr 2020 18:33:39 +0300 Subject: [PATCH] Increase releases limit --- helpers/github/github-api.psm1 | 21 +++++++++++++++++-- .../generate-versions-manifest.ps1 | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/helpers/github/github-api.psm1 b/helpers/github/github-api.psm1 index fef64a5..2634423 100644 --- a/helpers/github/github-api.psm1 +++ b/helpers/github/github-api.psm1 @@ -60,9 +60,26 @@ class GitHubApi return $this.InvokeRestMethod($url, 'Post', $null, $requestBody) } - [object] GetGitHubReleases(){ + [array] GetReleases(){ $url = "releases" - return $this.InvokeRestMethod($url, 'GET', $null, $null) + $releases = @() + $pageNumber = 1 + $releaseNumberLimit = 10000 + + while ($releases.Count -le $releaseNumberLimit) + { + $requestParams = "page=${pageNumber}&per_page=100" + [array] $response = $this.InvokeRestMethod($url, 'GET', $requestParams, $null) + + if ($response.Count -eq 0) { + break + } else { + $releases += $response + $pageNumber++ + } + } + + return $releases } [string] hidden BuildUrl([string]$Url, [string]$RequestParams) { diff --git a/helpers/packages-generation/generate-versions-manifest.ps1 b/helpers/packages-generation/generate-versions-manifest.ps1 index 81973e9..52b652d 100644 --- a/helpers/packages-generation/generate-versions-manifest.ps1 +++ b/helpers/packages-generation/generate-versions-manifest.ps1 @@ -153,6 +153,6 @@ function Build-VersionsManifest { } $gitHubApi = Get-GitHubApi -AccountName $GitHubRepositoryOwner -ProjectName $GitHubRepositoryName -AccessToken $GitHubAccessToken -$releases = $gitHubApi.GetGitHubReleases() +$releases = $gitHubApi.GetReleases() $versionIndex = Build-VersionsManifest $releases $versionIndex | ConvertTo-Json -Depth 5 | Out-File $OutputFile -Encoding UTF8NoBOM -Force