Skip to content

Commit 1d24b9f

Browse files
committed
addresses feedback
1 parent c2ea649 commit 1d24b9f

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

eng/scripts/Test-ChangelogEntry.ps1

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/env pwsh
1+
#!/usr/bin/env pwsh
22
#Requires -Version 7
33

44
# Validates that a PR includes a changelog entry or has the 'skip-changelog' label.
@@ -24,13 +24,20 @@ if ($prNumber) {
2424
Write-Host "PR #$prNumber labels: $($prLabels -join ', ')"
2525
}
2626
catch {
27-
Write-Warning "Failed to fetch PR labels from GitHub API: $_"
27+
Write-Error "Failed to fetch PR labels from GitHub API for PR #$prNumber. Unable to validate whether the 'skip-changelog' label is present. Ensure the GitHub authentication step ran and GH_TOKEN is available, then retry. Underlying error: $_"
28+
exit 1
2829
}
2930
}
3031

3132
Push-Location $RepoRoot
3233
try {
33-
$changedFiles = git diff --name-only --diff-filter=A "origin/main...HEAD" 2>&1
34+
$diffRange = "origin/main...HEAD"
35+
$changedFiles = git diff --name-only --diff-filter=AM $diffRange 2>&1
36+
if ($LASTEXITCODE -ne 0) {
37+
$gitError = ($changedFiles | Out-String).Trim()
38+
Write-Error "Failed to determine changed files with 'git diff --name-only --diff-filter=AM $diffRange'. $gitError"
39+
exit 1
40+
}
3441
$hasChangelog = $changedFiles | Where-Object { $_ -match 'changelog-entries/.*\.yml$' -or $_ -match 'CHANGELOG\.md'}
3542

3643
if ($hasChangelog) {
@@ -48,7 +55,7 @@ try {
4855
exit 0
4956
}
5057

51-
Write-Host "No changelog entry and no 'skip-changelog' label. If changelog entry is not required, add the 'skip-changelog' label to the PR to bypass this check. Or add a changelog entry TO the PR."
58+
Write-Error "Add a changelog entry to the PR or apply the 'skip-changelog' label."
5259
exit 1
5360
}
5461
finally {

0 commit comments

Comments
 (0)