Skip to content

Commit c6be108

Browse files
authored
{Misc.} Updated SyncSquadMapping script (#33108)
1 parent 692b407 commit c6be108

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

tools/Github/ParseSquadMappingList.ps1

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,27 @@ function TryParseLabelValue {
4848
return $null
4949
}
5050

51+
function NormalizeMentioneeValue {
52+
[CmdletBinding()]
53+
param(
54+
[string] $Mentionee
55+
)
56+
57+
if ([string]::IsNullOrWhiteSpace($Mentionee)) {
58+
return $Mentionee
59+
}
60+
61+
if ($Mentionee -match '^[^/]+/[^/]+$') {
62+
return $Mentionee
63+
}
64+
65+
if ($Mentionee -match '^act-[a-z0-9-]+-squad$') {
66+
return "Azure/$Mentionee"
67+
}
68+
69+
return $Mentionee
70+
}
71+
5172
function GetSquadMappingFromWiki {
5273
[CmdletBinding()]
5374
param(
@@ -360,7 +381,9 @@ function AddSquadLabelsToYaml {
360381
if ($lineAtB -match '^\s*mentionees:\s*$') { $mentioneesIndent = $indentAtB; continue }
361382
if ($lineAtB -match '^\s*-\s+(\S+)\s*$') {
362383
if ($mentionItemIndent -lt 0) { $mentionItemIndent = $indentAtB }
363-
$existingMentions[$Matches[1]] = $true
384+
$existingMention = $Matches[1]
385+
$existingMentions[$existingMention] = $true
386+
$existingMentions[(NormalizeMentioneeValue -Mentionee $existingMention)] = $true
364387
$lastMentionEnd = $b
365388
}
366389
}
@@ -370,8 +393,9 @@ function AddSquadLabelsToYaml {
370393
if ($mentionItemIndent -lt 0) { $mentionItemIndent = ($mentioneesIndent -gt 0) ? $mentioneesIndent : ($listIndentLength + 4) }
371394
$mentionInsertLines = [System.Collections.Generic.List[string]]::new()
372395
foreach ($squadLabel in $labelsToAdd) {
373-
if (-not $existingMentions.ContainsKey($squadLabel)) {
374-
$mentionInsertLines.Add((" " * $mentionItemIndent) + "- $squadLabel")
396+
$mentioneeValue = NormalizeMentioneeValue -Mentionee $squadLabel
397+
if (-not $existingMentions.ContainsKey($mentioneeValue)) {
398+
$mentionInsertLines.Add((" " * $mentionItemIndent) + "- $mentioneeValue")
375399
}
376400
}
377401
if ($mentionInsertLines.Count -gt 0) {

0 commit comments

Comments
 (0)