Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 9799 (#2015)
Browse files Browse the repository at this point in the history
* resolve issue with matrix collation when multiple matrix configs are being resolved

---------

Co-authored-by: Scott Beddall <[email protected]>
  • Loading branch information
azure-sdk and scbedd authored Feb 8, 2025
1 parent 80a4c26 commit 8452ce5
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions eng/common/scripts/Helpers/Package-Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

if (-not $groupedDictionary.ContainsKey($key)) {
$groupedDictionary[$key] = @()
}

# Add the current item to the array for this key
$groupedDictionary[$key] += $item
$groupedDictionary[$key] += $item
}
}

return $groupedDictionary
Expand Down

0 comments on commit 8452ce5

Please sign in to comment.