Fix comments

pull/5/head
MaksimZhukov 5 years ago
parent 17f3be07b9
commit e09bde7dec

@ -37,25 +37,23 @@ Write-Host "Get the packages list from $ManifestLink"
[Version[]] $formattedVersions = Format-Versions -Versions $versionsFromDist [Version[]] $formattedVersions = Format-Versions -Versions $versionsFromDist
if (-not ([string]::IsNullOrEmpty($VersionFilterToInclude))) { if ($VersionFilterToInclude) {
$formattedVersions = Filter-Versions -Versions $formattedVersions ` $formattedVersions = Filter-Versions -Versions $formattedVersions `
-VersionFilter $VersionFilterToInclude ` -VersionFilter $VersionFilterToInclude `
-IncludeVersions $true -IncludeVersions $true
} }
if (-not ([string]::IsNullOrEmpty($VersionFilterToExclude))) { if ($VersionFilterToExclude) {
$formattedVersions = Filter-Versions -Versions $formattedVersions ` $formattedVersions = Filter-Versions -Versions $formattedVersions `
-VersionFilter $VersionFilterToExclude ` -VersionFilter $VersionFilterToExclude `
-IncludeVersions $false -IncludeVersions $false
} }
$versionsToBuild = Get-VersionsToBuild -VersionsFromManifest $versionsFromManifest ` $versionsToBuild = Skip-ExistingVersions -VersionsFromManifest $versionsFromManifest `
-VersionsFromDist $formattedVersions -VersionsFromDist $formattedVersions
if ([string]::IsNullOrEmpty($versionsToBuild)) { if ($versionsToBuild) {
Write-Host "There isn't versions to build"
return $null
} else {
Write-Host "The following versions are available to build:`n$versionsToBuild" Write-Host "The following versions are available to build:`n$versionsToBuild"
return "$versionsToBuild" } else {
Write-Host "There isn't versions to build"
} }

@ -8,16 +8,15 @@ function Format-Versions {
foreach($version in $Versions) { foreach($version in $Versions) {
$substredVersion = $null $substredVersion = $null
# We cut a string from index of first digit because initially it has invalid format (v14.4.0 or go1.14.4) # Cut a string from index of first digit because initially it has invalid format (v14.4.0 or go1.14.4)
if ($version -match '(?<number>\d)') { if (-not ($version -match '(?<number>\d)')) {
$firstDigitIndex = $version.indexof($Matches.number)
$substredVersion = $version.substring($firstDigitIndex)
} else {
Write-Host "Invalid version format - $version" Write-Host "Invalid version format - $version"
exit 1 exit 1
} }
$firstDigitIndex = $version.indexof($Matches.number)
$substredVersion = $version.substring($firstDigitIndex)
# We filter versions to exclude unstable (for example: "go1.15beta1") # Filter versions to exclude unstable (for example: "go1.15beta1")
# Valid version format: x.x or x.x.x # Valid version format: x.x or x.x.x
if ($substredVersion -notmatch '^\d+\.+\d+\.*\d*$') { if ($substredVersion -notmatch '^\d+\.+\d+\.*\d*$') {
continue continue
@ -54,14 +53,14 @@ function Filter-Versions {
return $filteredVersions return $filteredVersions
} }
function Get-VersionsToBuild { function Skip-ExistingVersions {
param ( param (
[Parameter(Mandatory)] [string[]] $VersionsFromManifest, [Parameter(Mandatory)] [string[]] $VersionsFromManifest,
[Parameter(Mandatory)] [string[]] $VersionsFromDist [Parameter(Mandatory)] [string[]] $VersionsFromDist
) )
[System.Collections.ArrayList]$versionsToBuid = $VersionsFromDist $newVersions = @()
$VersionsFromManifest | ForEach-Object { $versionsToBuid.Remove($_) } $newVersions += $VersionsFromDist | Where-Object { $VersionsFromManifest -notcontains $_ }
return $versionsToBuid return $newVersions
} }
Loading…
Cancel
Save