Skip to content

Fix milestone fallback: inflight/candidate reads from main, not staging branch#35054

Merged
PureWeen merged 1 commit into
mainfrom
fix/milestone-use-main-versions
Apr 21, 2026
Merged

Fix milestone fallback: inflight/candidate reads from main, not staging branch#35054
PureWeen merged 1 commit into
mainfrom
fix/milestone-use-main-versions

Conversation

@PureWeen
Copy link
Copy Markdown
Member

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Summary

Fix milestone fallback for inflight/* and darc/* branches to read from origin/main instead of the staging branch itself.

Problem

PRs merged to inflight/candidate were milestoned as SR6 because inflight/candidate has PatchVersion=60. But those PRs will ultimately ship in SR7 (when the Candidate merges to main, which is at PatchVersion=70).

Fix

For staging branches (inflight/*, darc/*), read Versions.props from origin/main instead of origin/{base.ref}. These branches always feed into main, so main's version is the correct target.

All other branches continue reading from origin/{base.ref} directly.

Validated

PR Base Before After
#34959 inflight/candidate SR6 (wrong) SR7 ✅
#35040 inflight/current SR7 SR7 ✅
#34969 net11.0 preview1 preview4 ✅
#34620 main (on SR6 branch) SR6 SR6 ✅

91 Pester tests pass.

Copilot AI review requested due to automatic review settings April 21, 2026 02:25
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 21, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 35054

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 35054"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts milestone drift detection so that PRs targeting staging branches (inflight/*, darc/*) derive version info from origin/main (the eventual shipping target) rather than from potentially stale staging-branch Versions.props.

Changes:

  • Update the fallback path in Invoke-AnalyzeSinglePr to read Versions.props from origin/main for inflight/* and darc/* base refs; otherwise read from origin/<baseRef>.
  • Fix Get-VersionFromGitRef fetching behavior to avoid attempting to fetch origin/origin/<branch> when the input already includes an origin/ prefix.
  • Add a “live validation guide” comment block to the Pester test file (but it needs updates to match the new behavior).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
.github/scripts/Fix-MilestoneDrift.ps1 Implements the new fallback source-of-truth (main for staging branches) and corrects the git fetch refspec handling.
.github/scripts/Fix-MilestoneDrift.Tests.ps1 Adds documentation for manual validation steps; currently contains expectations that conflict with the updated staging-branch behavior.

Comment on lines +29 to +32
# 1. PR merged to inflight/current — should read Versions.props from origin/inflight/current
pwsh -File .github/scripts/Fix-MilestoneDrift.ps1 -PrNumber 34228 -RepoPath . -Verbose
# Expected: reads from origin/inflight/current, milestone matches current PatchVersion on that branch

Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The live validation guide is now out of date: the script’s new fallback logic reads Versions.props from origin/main for staging branches (inflight/, darc/), but this example still says inflight/current should read from origin/inflight/current. Please update the guidance to reflect the new behavior and expected output.

Copilot uses AI. Check for mistakes.
Comment on lines +57 to +60
Key things to verify after changes:
- inflight/current PRs read from origin/inflight/current (not stale merge commit)
- net11.0 PRs read from origin/net11.0 (never from origin/main)
- PRs on release branches get the milestone from the branch name (not Versions.props)
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These verification bullets don’t match the updated behavior: inflight/* and darc/* PRs should now read Versions.props from origin/main, not origin/inflight/current. Updating this list will prevent future changes from being validated against the old expectations.

Copilot uses AI. Check for mistakes.
Comment thread .github/scripts/Fix-MilestoneDrift.ps1 Outdated
Comment on lines +594 to +603
# the PR was merged to.
$mainBranch = Get-MainBranchForVersion $detectedMajor $Repo
$devBranch = "origin/$mainBranch"
$branchVersionInfo = Get-VersionFromGitRef $devBranch $Repo
if ($branchVersionInfo) {
$versionInfo = $branchVersionInfo
$ReleaseTag = $branchVersionInfo.Tag
$preLabel = $branchVersionInfo.PreLabel
$preIter = if ($branchVersionInfo.PreIter) { $branchVersionInfo.PreIter } else { 0 }
$preDisplay = if ($branchVersionInfo.PreLabel) { " ($($branchVersionInfo.PreLabel)$($branchVersionInfo.PreIter))" } else { "" }
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new branch-selection behavior for the fallback path (choosing origin/main for inflight/* and darc/; otherwise origin/) isn’t covered by the existing Pester tests. Consider extracting the dev-branch selection into a small pure helper (e.g., taking BaseRef and returning the git ref) and add unit tests for inflight/, darc/, main, net11.0, and release/ cases using Pester without requiring live git/gh access.

Copilot uses AI. Check for mistakes.
@PureWeen PureWeen force-pushed the fix/milestone-use-main-versions branch 2 times, most recently from 487e8d8 to 1543ba1 Compare April 21, 2026 16:37
@PureWeen
Copy link
Copy Markdown
Member Author

PureWeen commented Apr 21, 2026

PR #35054 — Multi-Model Code Review (Final)

CI Status: ⚠️ maui-pr shows "fail" with 0 elapsed — not triggered (script-only PR, expected)

Prior reviews: Copilot reviewer comments addressed (stale docs). Previous round: 2/3 clean, 1 timed out.

Review Results

  • Reviewer 1: No issues found. Confirmed grep is safe ([int] PrNum, BRE literal parens), fallback chain preserved.
  • Reviewer 2: Timed out.
  • Reviewer 3: Raised concern about release-branch PRs falling through to main fallback.

Adversarial Consensus

Reviewer 3's finding — REJECTED (1/3, disputed):

"PRs targeting release/* could fall through to main fallback if grep fails"

For a PR merged directly to release/10.0.1xx-sr6, the merge commit IS on that branch, so merge-base --is-ancestor always succeeds at step 1. The main fallback is never reached. Confirmed by adversarial check.

Summary

Change Status
Fallback reads from Get-MainBranchForVersion instead of origin/{base.ref} ✅ Correct — all staging branches feed into main
Grep fallback for rebased/cherry-picked PRs ✅ Correct — safe, literal match, no injection
Updated validation guide docs ✅ Matches new behavior

Recommended Action

Approve — Zero confirmed issues. All validation passes. Diff is clean (47 insertions, 32 deletions).

Two fixes to milestone detection:

1. Fallback reads Versions.props from the development branch (main
   for .NET 10, net11.0 for .NET 11) instead of origin/{base.ref}.
   Staging branches like inflight/candidate have stale PatchVersion
   but their PRs ultimately ship on main's version.

2. Find-ReleaseBranchForCommit falls back to git log --grep when
   ancestry check fails. Handles rebases and cherry-picks where the
   commit SHA changes but the PR number '(#NNNNN)' is preserved in
   the commit message.

Updated live validation guide to match new behavior.

Validated:
- #34667 (rebased to SR6) → found via grep → .NET 10 SR6 ✅
- #34959 (inflight/candidate) → reads main → .NET 10 SR7 ✅
- #34620 (on SR6 branch) → ancestry → .NET 10 SR6 ✅
- #34969 (net11.0) → reads net11.0 → .NET 11.0-preview4 ✅

91 Pester tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@PureWeen PureWeen force-pushed the fix/milestone-use-main-versions branch from 1543ba1 to 5f09344 Compare April 21, 2026 18:06
@PureWeen PureWeen merged commit 23d6a44 into main Apr 21, 2026
4 of 5 checks passed
@PureWeen PureWeen deleted the fix/milestone-use-main-versions branch April 21, 2026 20:34
@github-actions github-actions Bot added this to the .NET 10 SR7 milestone Apr 21, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators May 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants