Sync eng/common directory with azure-sdk-tools for PR 9799 (#6402)
* resolve issue with matrix collation when multiple matrix configs are being resolved --------- Co-authored-by: Scott Beddall <scbedd@microsoft.com>
This commit is contained in:
parent
b7bd086776
commit
ac2c03cce9
@ -210,14 +210,33 @@ function Group-ByObjectKey {
|
||||
$groupedDictionary = @{}
|
||||
|
||||
foreach ($item in $Items) {
|
||||
$key = Get-ObjectKey $item."$GroupByProperty"
|
||||
# if the item is an array, we need to group by each element in the array
|
||||
# however if it's an empty array we want to treat it as a single item
|
||||
if ($item."$GroupByProperty" -and $item."$GroupByProperty" -is [array]) {
|
||||
foreach ($GroupByPropertyValue in $item."$GroupByProperty") {
|
||||
$key = Get-ObjectKey $GroupByPropertyValue
|
||||
|
||||
if (-not $groupedDictionary.ContainsKey($key)) {
|
||||
$groupedDictionary[$key] = @()
|
||||
if (-not $groupedDictionary.ContainsKey($key)) {
|
||||
$groupedDictionary[$key] = @()
|
||||
}
|
||||
|
||||
$groupedDictionary[$key] += $item
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($item."$GroupByProperty") {
|
||||
$key = Get-ObjectKey $item."$GroupByProperty"
|
||||
}
|
||||
else {
|
||||
$key = "unset"
|
||||
}
|
||||
|
||||
# Add the current item to the array for this key
|
||||
$groupedDictionary[$key] += $item
|
||||
if (-not $groupedDictionary.ContainsKey($key)) {
|
||||
$groupedDictionary[$key] = @()
|
||||
}
|
||||
|
||||
$groupedDictionary[$key] += $item
|
||||
}
|
||||
}
|
||||
|
||||
return $groupedDictionary
|
||||
|
||||
Loading…
Reference in New Issue
Block a user