Skip to content

[devops] Fix PR latest-commit detection#25231

Merged
rolfbjarne merged 2 commits intomainfrom
dev/rolf/devops-detect-last-commit
Apr 24, 2026
Merged

[devops] Fix PR latest-commit detection#25231
rolfbjarne merged 2 commits intomainfrom
dev/rolf/devops-detect-last-commit

Conversation

@rolfbjarne
Copy link
Copy Markdown
Member

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.

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>
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

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_PR environment 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.

Comment thread tools/devops/automation/scripts/GitHub.psm1 Outdated
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

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>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne marked this pull request as ready for review April 24, 2026 07:10
@rolfbjarne rolfbjarne enabled auto-merge (squash) April 24, 2026 07:11
@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #3cc6e0e] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 3cc6e0e212b9408d8215a13fb94af1cdad964005 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #3cc6e0e] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 3cc6e0e212b9408d8215a13fb94af1cdad964005 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 3cc6e0e212b9408d8215a13fb94af1cdad964005 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [CI Build #3cc6e0e] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 3cc6e0e212b9408d8215a13fb94af1cdad964005 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

🚀 [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
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 6 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 12 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 11 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 3cc6e0e212b9408d8215a13fb94af1cdad964005 [PR build]

@rolfbjarne rolfbjarne merged commit 7886516 into main Apr 24, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants