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
if (-not ([string]::IsNullOrEmpty($VersionFilterToInclude))) {
if ($VersionFilterToInclude) {
$formattedVersions = Filter-Versions -Versions $formattedVersions `
-VersionFilter $VersionFilterToInclude `
-IncludeVersions $true
}
if (-not ([string]::IsNullOrEmpty($VersionFilterToExclude))) {
if ($VersionFilterToExclude) {
$formattedVersions = Filter-Versions -Versions $formattedVersions `
-VersionFilter $VersionFilterToExclude `
-IncludeVersions $false
}
$versionsToBuild = Get-VersionsToBuild -VersionsFromManifest $versionsFromManifest `
-VersionsFromDist $formattedVersions
$versionsToBuild = Skip-ExistingVersions -VersionsFromManifest $versionsFromManifest `
-VersionsFromDist $formattedVersions
if ([string]::IsNullOrEmpty($versionsToBuild)) {
Write-Host "There isn't versions to build"
return $null
} else {
if ($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) {
$substredVersion = $null
# We 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)') {
$firstDigitIndex = $version.indexof($Matches.number)
$substredVersion = $version.substring($firstDigitIndex)
} else {
# Cut a string from index of first digit because initially it has invalid format (v14.4.0 or go1.14.4)
if (-not ($version -match '(?<number>\d)')) {
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
if ($substredVersion -notmatch '^\d+\.+\d+\.*\d*$') {
continue
@ -54,14 +53,14 @@ function Filter-Versions {
return $filteredVersions
}
function Get-VersionsToBuild {
function Skip-ExistingVersions {
param (
[Parameter(Mandatory)] [string[]] $VersionsFromManifest,
[Parameter(Mandatory)] [string[]] $VersionsFromDist
)
[System.Collections.ArrayList]$versionsToBuid = $VersionsFromDist
$VersionsFromManifest | ForEach-Object { $versionsToBuid.Remove($_) }
$newVersions = @()
$newVersions += $VersionsFromDist | Where-Object { $VersionsFromManifest -notcontains $_ }
return $versionsToBuid
return $newVersions
}
Loading…
Cancel
Save