From a9007dd128ab73fa0b2d2a227b7fe07fa9c3b454 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 29 Apr 2026 15:50:31 -0500 Subject: [PATCH] Fix milestone detection for inflight PRs that missed release cutoff When a PR merges to inflight/* branches, the script previously trusted Versions.props to determine the milestone. But Versions.props only indicates what version was being developed, not whether the PR actually shipped. PRs that merge to inflight after the candidate cutoff would be incorrectly milestoned to the already-shipped release. Now checks if the PR number appears in the tag's commit range (via candidate merge commit messages). If the tag exists but the PR is not in the range, it advances to the next SR version. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/scripts/Fix-MilestoneDrift.ps1 | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/scripts/Fix-MilestoneDrift.ps1 b/.github/scripts/Fix-MilestoneDrift.ps1 index d16491b0fe3f..0b061fea8053 100644 --- a/.github/scripts/Fix-MilestoneDrift.ps1 +++ b/.github/scripts/Fix-MilestoneDrift.ps1 @@ -592,6 +592,36 @@ function Invoke-AnalyzeSinglePr([int]$PrNum, [string]$ReleaseTag, [string]$Repo) $preIter = if ($versionInfo.PreIter) { $versionInfo.PreIter } else { 0 } $preDisplay = if ($versionInfo.PreLabel) { " ($($versionInfo.PreLabel)$($versionInfo.PreIter))" } else { "" } Write-Host " Version from Versions.props at merge commit: $ReleaseTag$preDisplay" + + # Step 2b: For PRs merged to inflight/* branches, verify the PR + # actually shipped in the detected version. Inflight PRs have merge + # commits on the inflight branch (not the release branch), so we check + # by PR number in the tag's commit range instead of commit ancestry. + if ($pr.BaseRef -match '^inflight/' -and $ReleaseTag) { + $allTags = Get-AllTags $Repo + if ($ReleaseTag -in $allTags) { + $prev = Find-PreviousTag $ReleaseTag $allTags + $prsInTag = if ($prev) { + Get-PrNumbersBetweenTags $prev $ReleaseTag $Repo + } else { + Get-PrNumbersReachableFromTag $ReleaseTag $Repo + } + if ($PrNum -notin $prsInTag) { + # PR number not found in the tag range — PR missed this release + $patch = Get-PatchVersion $ReleaseTag + $major = if ($ReleaseTag -match '^(\d+)\.') { [int]$Matches[1] } else { $detectedMajor } + $nextPatch = $patch + 10 + $nextTag = "$major.0.$nextPatch" + Write-Host " ⚠️ PR #$PrNum merged to $($pr.BaseRef) but is NOT in tag $ReleaseTag — advancing to $nextTag" + $ReleaseTag = $nextTag + $versionInfo = $null # Clear so downstream uses $ReleaseTag + $preLabel = $null + $preIter = 0 + } else { + Write-Host " ✅ PR #$PrNum merged to $($pr.BaseRef) and found in tag $ReleaseTag (via candidate)" + } + } + } } } }