Skip to content

Commit 7536879

Browse files
vaindclaude
andcommitted
fix(updater): Pass OriginalTag to post-update script on second run
When the updater creates a new PR and runs the update-dependency script a second time, it was not passing the OriginalTag parameter. This caused the script to fail validation since Tag requires OriginalTag to be set. Changes: - Updated action.yml to pass OriginalTag on second script execution - Added unit test for explicit Tag/OriginalTag parameters - Added validation test to ensure Tag fails without OriginalTag All 34 tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent e6b456f commit 7536879

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

updater/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ runs:
288288
DEPENDENCY_PATH: ${{ inputs.path }}
289289
POST_UPDATE_SCRIPT: ${{ inputs.post-update-script }}
290290
GH_TOKEN: ${{ inputs.api-token }}
291-
run: ${{ github.action_path }}/scripts/update-dependency.ps1 -Path $env:DEPENDENCY_PATH -Tag '${{ steps.target.outputs.latestTag }}' -PostUpdateScript $env:POST_UPDATE_SCRIPT
291+
run: ${{ github.action_path }}/scripts/update-dependency.ps1 -Path $env:DEPENDENCY_PATH -Tag '${{ steps.target.outputs.latestTag }}' -OriginalTag '${{ steps.target.outputs.originalTag }}' -PostUpdateScript $env:POST_UPDATE_SCRIPT
292292

293293
- name: Update Changelog
294294
if: ${{ inputs.changelog-entry == 'true' && ( steps.target.outputs.latestTag != steps.target.outputs.originalTag ) && ( steps.root.outputs.changed == 'false') }}

updater/tests/update-dependency.Tests.ps1

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,63 @@ param([string] $originalVersion, [string] $newVersion)
515515
Remove-Item $postUpdateScript -ErrorAction SilentlyContinue
516516
}
517517

518+
It 'runs PowerShell post-update script when Tag and OriginalTag are explicitly provided' {
519+
$testFile = "$testDir/test.properties"
520+
$repo = 'https://github.com/getsentry/sentry-cli'
521+
@("repo=$repo", 'version=0.27.0') | Out-File $testFile
522+
523+
$postUpdateScript = "$testDir/post-update-explicit.ps1"
524+
$markerFile = "$testDir/post-update-marker-explicit.txt"
525+
@'
526+
param([string] $originalVersion, [string] $newVersion)
527+
"$originalVersion|$newVersion" | Out-File
528+
'@ + " '$markerFile'" | Out-File $postUpdateScript
529+
530+
# Simulate the second run where we explicitly set Tag and OriginalTag
531+
$params = @{
532+
Path = $testFile
533+
Tag = '0.28.0'
534+
OriginalTag = '0.27.0'
535+
PostUpdateScript = $postUpdateScript
536+
}
537+
$result = & "$PSScriptRoot/../scripts/update-dependency.ps1" @params
538+
if (-not $?) {
539+
throw $result
540+
}
541+
542+
# Verify post-update script was executed with correct versions
543+
Test-Path $markerFile | Should -Be $true
544+
$markerContent = Get-Content $markerFile
545+
$markerContent | Should -Match '^0\.27\.0\|0\.28\.0$'
546+
547+
# Clean up
548+
Remove-Item $markerFile -ErrorAction SilentlyContinue
549+
Remove-Item $postUpdateScript -ErrorAction SilentlyContinue
550+
}
551+
552+
It 'fails when Tag is provided without OriginalTag' {
553+
$testFile = "$testDir/test.properties"
554+
$repo = 'https://github.com/getsentry/sentry-cli'
555+
@("repo=$repo", 'version=0.27.0') | Out-File $testFile
556+
557+
$postUpdateScript = "$testDir/post-update-fail.ps1"
558+
@'
559+
param([string] $originalVersion, [string] $newVersion)
560+
"$originalVersion|$newVersion" | Out-File marker.txt
561+
'@ | Out-File $postUpdateScript
562+
563+
# This should fail because Tag requires OriginalTag
564+
$params = @{
565+
Path = $testFile
566+
Tag = '0.28.0'
567+
PostUpdateScript = $postUpdateScript
568+
}
569+
{ & "$PSScriptRoot/../scripts/update-dependency.ps1" @params } | Should -Throw '*Expected*to be different*'
570+
571+
# Clean up
572+
Remove-Item $postUpdateScript -ErrorAction SilentlyContinue
573+
}
574+
518575
It 'runs bash post-update script with version arguments' -Skip:$IsWindows {
519576
$testFile = "$testDir/test.properties"
520577
$repo = 'https://github.com/getsentry/sentry-cli'

0 commit comments

Comments
 (0)