Skip to content

Commit 0ecab84

Browse files
Fix stale comment and improve backtick escaping in PR comment
1 parent f7a67b8 commit 0ecab84

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/main.ps1

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,7 @@ LogGroup 'Calculate Job Run Conditions:' {
256256
$isOpenOrLabeledPR = $isPR -and $pullRequestAction -in @('opened', 'reopened', 'synchronize', 'labeled')
257257

258258
# Check if important files have changed in the PR
259-
# Important files for module and docs publish:
260-
# - .github/workflows/Process-PSModule.yml
261-
# - src/**
262-
# - examples/**
263-
# - README.md
259+
# Important files are determined by the configured ImportantFilePatterns setting
264260
$hasImportantChanges = $false
265261
if ($isPR -and $pullRequest.Number) {
266262
LogGroup 'Check for Important File Changes' {
@@ -299,8 +295,14 @@ LogGroup 'Calculate Job Run Conditions:' {
299295
# Add a comment to open PRs explaining why build/test is skipped (best-effort, may fail if permissions not granted)
300296
if ($isOpenOrUpdatedPR) {
301297
$patternRows = ($importantPatterns | ForEach-Object {
302-
$escapedPattern = $_.Replace('|', '\|').Replace('``', '\``')
303-
"| ``$escapedPattern`` | Matches files where path matches this pattern |"
298+
$escapedPattern = $_.Replace('|', '\|')
299+
$backtickMatches = [regex]::Matches($escapedPattern, '`+')
300+
$maxRun = 0
301+
foreach ($m in $backtickMatches) {
302+
if ($m.Value.Length -gt $maxRun) { $maxRun = $m.Value.Length }
303+
}
304+
$codeDelimiter = '``' * ($maxRun + 1)
305+
"| ${codeDelimiter}${escapedPattern}${codeDelimiter} | Matches files where path matches this pattern |"
304306
}) -join "`n"
305307
$commentBody = @"
306308
### No Significant Changes Detected

0 commit comments

Comments
 (0)