Skip to content

Commit 14255f0

Browse files
vaindclaude
andcommitted
fix: handle git diff exit codes properly in PowerShell
- Add proper error action preference settings to match CI environment - Handle git diff exit code 1 (differences found) as expected behavior - Use explicit exit 0 to ensure clean script termination - Fixes updater-pr-creation CI failures with PSNativeCommandErrorActionPreference 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c4b84ee commit 14255f0

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

updater/scripts/get-changelog.ps1

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ param(
55
)
66

77
Set-StrictMode -Version latest
8+
$PSNativeCommandErrorActionPreference = $true
9+
$ErrorActionPreference = 'Stop'
810

911
$prefix = 'https?://(www\.)?github.com/'
1012
if (-not ($RepoUrl -match "^$prefix([^/]+)/([^/]+?)(?:\.git)?/?$")) {
@@ -63,7 +65,17 @@ try {
6365
Write-Host "Generating changelog diff between $OldTag and $NewTag..."
6466

6567
# Generate diff using git diff --no-index
66-
$fullDiff = git diff --no-index $oldChangelogPath $newChangelogPath
68+
# git diff returns exit code 1 when differences are found, which is expected behavior
69+
# We need to handle this properly when PSNativeCommandErrorActionPreference is enabled
70+
$fullDiff = & {
71+
$oldErrorActionPreference = $ErrorActionPreference
72+
$ErrorActionPreference = 'Continue'
73+
try {
74+
git diff --no-index $oldChangelogPath $newChangelogPath
75+
} finally {
76+
$ErrorActionPreference = $oldErrorActionPreference
77+
}
78+
}
6779

6880
# The first lines are diff metadata, skip them
6981
$fullDiff = $fullDiff -split "`n" | Select-Object -Skip 4
@@ -132,3 +144,6 @@ try {
132144
Remove-Item -Recurse -Force -ErrorAction Continue $tmpDir
133145
}
134146
}
147+
148+
# Ensure clean exit
149+
exit 0

0 commit comments

Comments
 (0)