[devops] Fix PR latest-commit detection#25231
Conversation
Treat PR merge refs as PR builds regardless of the reported build reason, and consider synthetic merge commits current when one of their parents matches the PR head. Also pass the checkout template's isPR flag correctly so the fixed commit hash is used for PR comment handling. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR improves Azure DevOps ↔ GitHub PR build handling so PR comment hiding/placement logic correctly recognizes PR merge-ref builds and properly identifies the “latest” PR commit even when the build runs on a synthetic merge commit.
Changes:
- Pass the checkout template’s
IS_PRenvironment variable directly from the template parameter (so PR merge-ref builds are treated as PR builds). - Update PR detection and “latest commit” detection to handle PR merge refs and synthetic merge commits (by checking merge parents and multiple candidate hashes).
- Extend PowerShell tests to cover the new PR detection and synthetic-merge latest-commit behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/devops/automation/templates/common/checkout.yml | Fixes propagation of isPR into IS_PR so PR builds use the correct commit hash for downstream comment logic. |
| tools/devops/automation/scripts/GitHub.psm1 | Enhances PR detection for merge refs and improves “latest commit in PR” detection with synthetic merge parent handling + caching. |
| tools/devops/automation/scripts/GitHub.Tests.ps1 | Adds/updates unit tests to validate the new PR detection and synthetic merge latest-commit logic. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Distinguish exit code 1 (not an ancestor) from 128+ (git error such as missing refs in a shallow checkout). Throw on unexpected exit codes so the outer try/catch falls back to the safe path instead of silently returning false. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #3cc6e0e] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #3cc6e0e] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #3cc6e0e] Build passed (Build macOS tests) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #3cc6e0e] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 156 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Treat PR merge refs as PR builds regardless of the reported build reason, and consider synthetic merge commits current when one of their parents matches the PR head. Also pass the checkout template's isPR flag correctly so the fixed commit hash is used for PR comment handling.