Build hash key with non-null arguments
This commit is contained in:
parent
e699d11db0
commit
a3c8483cdb
@ -139,14 +139,14 @@ function Invoke-Query($fields, $wiql, $output = $true)
|
|||||||
return $workItems
|
return $workItems
|
||||||
}
|
}
|
||||||
|
|
||||||
function BuildHashKeyNoNull()
|
function BuildHashKeyFromNonNullArgs()
|
||||||
{
|
{
|
||||||
$filterNulls = $args | Where-Object { $_ }
|
$filterNulls = $args | Where-Object { $_ }
|
||||||
# if we had any nulls then return null
|
# if we had any non-nulls then return it
|
||||||
if (!$filterNulls -or $args.Count -ne $filterNulls.Count) {
|
if (!$filterNulls) {
|
||||||
return $null
|
return $null
|
||||||
}
|
}
|
||||||
return BuildHashKey $args
|
return BuildHashKey @filterNulls
|
||||||
}
|
}
|
||||||
|
|
||||||
function BuildHashKey()
|
function BuildHashKey()
|
||||||
@ -241,11 +241,7 @@ function FindLatestPackageWorkItem($lang, $packageName, $groupId = $null, $outpu
|
|||||||
|
|
||||||
function FindPackageWorkItem($lang, $packageName, $version, $groupId = $null, $outputCommand = $true, $includeClosed = $false, $ignoreReleasePlannerTests = $true, $tag = $null)
|
function FindPackageWorkItem($lang, $packageName, $version, $groupId = $null, $outputCommand = $true, $includeClosed = $false, $ignoreReleasePlannerTests = $true, $tag = $null)
|
||||||
{
|
{
|
||||||
$keyArgs = @($lang, $packageName, $version)
|
$key = BuildHashKeyFromNonNullArgs $lang $packageName $version $groupId
|
||||||
if (![string]::IsNullOrWhiteSpace($groupId)) {
|
|
||||||
$keyArgs += $groupId
|
|
||||||
}
|
|
||||||
$key = BuildHashKeyNoNull @keyArgs
|
|
||||||
if ($key -and $packageWorkItems.ContainsKey($key)) {
|
if ($key -and $packageWorkItems.ContainsKey($key)) {
|
||||||
return $packageWorkItems[$key]
|
return $packageWorkItems[$key]
|
||||||
}
|
}
|
||||||
@ -304,11 +300,7 @@ function FindPackageWorkItem($lang, $packageName, $version, $groupId = $null, $o
|
|||||||
|
|
||||||
foreach ($wi in $workItems)
|
foreach ($wi in $workItems)
|
||||||
{
|
{
|
||||||
$localKeyArgs = @($wi.fields["Custom.Language"], $wi.fields["Custom.Package"], $wi.fields["Custom.PackageVersionMajorMinor"])
|
$localKey = BuildHashKeyFromNonNullArgs $wi.fields["Custom.Language"] $wi.fields["Custom.Package"] $wi.fields["Custom.PackageVersionMajorMinor"] $wi.fields["Custom.GroupId"]
|
||||||
if (![string]::IsNullOrWhiteSpace($wi.fields["Custom.GroupId"])) {
|
|
||||||
$localKeyArgs += $wi.fields["Custom.GroupId"]
|
|
||||||
}
|
|
||||||
$localKey = BuildHashKeyNoNull @localKeyArgs
|
|
||||||
if (!$localKey) {
|
if (!$localKey) {
|
||||||
$packageWorkItemWithoutKeyFields[$wi.id] = $wi
|
$packageWorkItemWithoutKeyFields[$wi.id] = $wi
|
||||||
Write-Host "Skipping package [$($wi.id)]$($wi.fields['System.Title']) which is missing required fields language, package, or version."
|
Write-Host "Skipping package [$($wi.id)]$($wi.fields['System.Title']) which is missing required fields language, package, or version."
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user