@@ -244,17 +244,16 @@ function Resolve-ReleasePullRequest {
244244 Resolves the pull request whose version label drives the release for a commit.
245245
246246 . DESCRIPTION
247- A push resolves the pull request associated with the pushed commit so a default-branch
248- release honours the merged pull request's version label. A manual dispatch on the default
249- branch is the documented recovery route for a failed or cancelled release run and targets
250- the same merge commit, so it must resolve the same pull request. Excluding it left the pull
251- request unresolved, and the version silently fell back to a patch bump through AutoPatching.
247+ A push and a default-branch dispatch resolve the exact merged pull request for the released
248+ commit. Dispatch uses the current branch tip, so it can recover an intended merge only while
249+ that merge is still the tip. Rerun the original workflow's failed jobs for an older commit.
252250
253251 When no pull request is selected, the outcome depends on why. A commit pushed directly to
254252 the default branch has no label to honour, so the release proceeds with the default patch
255253 bump. A commit associated with a merged default-branch pull request that does not match it
256- does carry a label, and applying a patch bump would publish a version nobody asked for. A
257- PowerShell Gallery version cannot be reclaimed, so that case throws instead.
254+ does carry a label, and applying a patch bump would publish a version nobody asked for.
255+ That case throws for an important default-branch push or a recovery dispatch, but not for a
256+ documentation-only push that cannot publish.
258257
259258 . OUTPUTS
260259 PSCustomObject with Resolved, indicating whether the lookup ran, and PullRequest, which is
@@ -264,7 +263,7 @@ function Resolve-ReleasePullRequest {
264263 Resolve-ReleasePullRequest -EventName workflow_dispatch -CommitSha $sha -DefaultBranch main `
265264 -IsManualDispatchToDefaultBranch $true -GetAssociatedPullRequest { param($Sha) $pulls }
266265
267- Resolves the merged pull request for a recovery dispatch so its version label is honoured .
266+ Resolves the merged pull request for a current-tip recovery dispatch so its label is honored .
268267 #>
269268 [Diagnostics.CodeAnalysis.SuppressMessageAttribute (' PSReviewUnusedParameter' , ' ' ,
270269 Justification = ' Parameters are used inside a LogGroup script block.' )]
@@ -293,6 +292,10 @@ function Resolve-ReleasePullRequest {
293292 [Parameter ()]
294293 [bool ] $IsManualDispatchToDefaultBranch ,
295294
295+ # Whether a default-branch push changes a configured important file.
296+ [Parameter ()]
297+ [bool ] $HasImportantChanges = $true ,
298+
296299 # Returns the pull requests GitHub associates with a commit. Takes the commit SHA.
297300 [Parameter (Mandatory )]
298301 [scriptblock ] $GetAssociatedPullRequest
@@ -307,7 +310,7 @@ function Resolve-ReleasePullRequest {
307310 return [pscustomobject ]@ { Resolved = $false ; PullRequest = $null }
308311 }
309312
310- LogGroup " Resolve pull request for commit [$CommitSha ]" {
313+ Set-GitHubLogGroup " Resolve pull request for commit [$CommitSha ]" {
311314 $associated = @ ((& $GetAssociatedPullRequest $CommitSha ) | Where-Object { $null -ne $_ })
312315 $pullRequest = Select-PullRequestForPush - PullRequest $associated `
313316 - DefaultBranch $DefaultBranch `
@@ -320,7 +323,7 @@ function Resolve-ReleasePullRequest {
320323
321324 # Only a release-bearing event can publish a wrong version. A push to a feature branch has
322325 # no release to get wrong, and its commit is legitimately claimed by an open pull request.
323- $isReleaseEvent = $IsPushToDefaultBranch -or $IsManualDispatchToDefaultBranch
326+ $isReleaseEvent = ( $IsPushToDefaultBranch -and $HasImportantChanges ) -or $IsManualDispatchToDefaultBranch
324327 $discarded = if ($isReleaseEvent ) {
325328 @ (Get-DiscardedReleasePullRequest - PullRequest $associated `
326329 - DefaultBranch $DefaultBranch `
@@ -334,8 +337,8 @@ function Resolve-ReleasePullRequest {
334337 ' The following merged pull request(s) are associated with it but none matches the commit ' +
335338 " being released: $ ( $discarded -join ' ; ' ) . " +
336339 ' Refusing to fall back to a patch bump, because a wrong version published to the ' +
337- ' PowerShell Gallery cannot be reclaimed. Re-run the workflow against the merge commit ' +
338- ' of the pull request you intend to release .'
340+ ' PowerShell Gallery cannot be reclaimed. Rerun the original workflow for the intended merge commit. ' +
341+ ' A default-branch dispatch can recover that commit only while it is still the branch tip .'
339342 )
340343 }
341344
0 commit comments