Skip to content

Commit 7137627

Browse files
authored
Update Update-Mgmt-CI.ps1 (#47879)
1 parent 0505f79 commit 7137627

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

eng/scripts/Update-Mgmt-CI.ps1

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
$packagesPath = "$PSScriptRoot/../../sdk"
44

55
$track2MgmtDirs = Get-ChildItem -Path "$packagesPath" -Directory -Recurse -Depth 1 | Where-Object { $_.Name -match "(Azure.ResourceManager.)" -and $(Test-Path("$($_.FullName)/src")) }
6-
6+
$newLine = [Environment]::NewLine
77
function Update-CIFile() {
88
param(
99
[string]$mgmtCiFile = ""
@@ -13,7 +13,7 @@ function Update-CIFile() {
1313

1414
$content = Get-Content $mgmtCiFile -Raw
1515

16-
if ($content -match "(?s)ServiceDirectory:\s*(?<sd>[^\r\n]+).*-\s*name:\s*(?<p>[^\r\n]+)")
16+
if ($content -match "(?s)ServiceDirectory:\s*(?<sd>[^$newLine]+).*-\s*name:\s*(?<p>[^$newLine]+)")
1717
{
1818
$serviceDirectory = $matches["sd"]
1919
$packageName = $matches["p"]
@@ -39,12 +39,12 @@ pr:
3939
- $relPackageDir
4040
"@
4141

42-
$content = $content -replace "(?s)pr:[^\r\n]*(\r\n([ ]+[^\r\n]*|))*", "$prtriggers`r`n`r`n"
43-
$content = $content -replace "(?s)trigger:[^\r\n]*(\r\n([ ]+[^\r\n]*|))*", "trigger: none`r`n"
42+
$content = $content -replace "(?s)pr:[^$newLine]*($newLine([ ]+[^$newLine]*|))*", "$prtriggers$newLine$newLine"
43+
$content = $content -replace "(?s)trigger:[^$newLine]*($newLine([ ]+[^$newLine]*|))*", "trigger: none$newLine"
4444

4545
if ($content -notmatch "LimitForPullRequest: true")
4646
{
47-
$content = $content -replace "(.*)Artifacts:", "`$1LimitForPullRequest: true`r`n`$1Artifacts:"
47+
$content = $content -replace "(.*)Artifacts:", "`$1LimitForPullRequest: true$newLine`$1Artifacts:"
4848
}
4949

5050
Set-Content -Path $mgmtCiFile $content -NoNewline
@@ -56,7 +56,7 @@ pr:
5656
{
5757
$ciContent = Get-Content $ciFile -Raw
5858

59-
$ciContent = $ciContent -replace "(?s)(paths:\r\n(\s+)include:\r\n(?:\s+-[^\r\n]*\r\n)*(?:\s+-\s+$relServiceDir/?\r\n)(?:\s+-[^\r\n]*\r\n)*)(?!\s+exclude:)", "`$1`$2exclude:`r`n`$2- $relPackageDir`r`n"
59+
$ciContent = $ciContent -replace "(?s)(paths:$newLine(\s+)include:$newLine(?:\s+-[^$newLine]*$newLine)*(?:\s+-\s+$relServiceDir/?$newLine)(?:\s+-[^$newLine]*$newLine)*)(?!\s+exclude:)", "`$1`$2exclude:$newLine`$2- $relPackageDir$newLine"
6060

6161
Set-Content -Path $ciFile $ciContent -NoNewline
6262
}

0 commit comments

Comments
 (0)