Skip to content

Commit 676fbfb

Browse files
azure-sdkscbedd
andauthored
Sync eng/common directory with azure-sdk-tools for PR 9799 (Azure#2086)
* resolve issue with matrix collation when multiple matrix configs are being resolved --------- Co-authored-by: Scott Beddall <[email protected]>
1 parent d1b1d7f commit 676fbfb

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

eng/common/scripts/Helpers/Package-Helpers.ps1

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,33 @@ function Group-ByObjectKey {
210210
$groupedDictionary = @{}
211211

212212
foreach ($item in $Items) {
213-
$key = Get-ObjectKey $item."$GroupByProperty"
213+
# if the item is an array, we need to group by each element in the array
214+
# however if it's an empty array we want to treat it as a single item
215+
if ($item."$GroupByProperty" -and $item."$GroupByProperty" -is [array]) {
216+
foreach ($GroupByPropertyValue in $item."$GroupByProperty") {
217+
$key = Get-ObjectKey $GroupByPropertyValue
214218

215-
if (-not $groupedDictionary.ContainsKey($key)) {
216-
$groupedDictionary[$key] = @()
219+
if (-not $groupedDictionary.ContainsKey($key)) {
220+
$groupedDictionary[$key] = @()
221+
}
222+
223+
$groupedDictionary[$key] += $item
224+
}
217225
}
226+
else {
227+
if ($item."$GroupByProperty") {
228+
$key = Get-ObjectKey $item."$GroupByProperty"
229+
}
230+
else {
231+
$key = "unset"
232+
}
233+
234+
if (-not $groupedDictionary.ContainsKey($key)) {
235+
$groupedDictionary[$key] = @()
236+
}
218237

219-
# Add the current item to the array for this key
220-
$groupedDictionary[$key] += $item
238+
$groupedDictionary[$key] += $item
239+
}
221240
}
222241

223242
return $groupedDictionary

0 commit comments

Comments
 (0)