Skip to content

Replace branch-mirror-status prompt file with PowerShell script#55111

Open
marcpopMSFT wants to merge 4 commits into
mainfrom
marcpopmsft-fix-branch-mirror-script
Open

Replace branch-mirror-status prompt file with PowerShell script#55111
marcpopMSFT wants to merge 4 commits into
mainfrom
marcpopmsft-fix-branch-mirror-script

Conversation

@marcpopMSFT

Copy link
Copy Markdown
Member

Supersedes #53982.

Replaces the branch-mirror-status.prompt.md prompt file with a standalone PowerShell script that checks whether public GitHub release branches have been mirrored to internal Azure DevOps repos.

Fix from #53982

The original PR used az rest --resource for AzDo API calls, which fails on Windows due to:

  1. Token acquisition issuesaz rest can't properly derive the Azure AD resource from AzDo URLs, causing it to skip authentication
  2. Unicode encoding errorsaz rest hits 'charmap' codec can't encode character when the response contains non-ASCII characters on Windows

Fix: Use az account get-access-token --resource <id> to acquire the bearer token once during prerequisite checks, then Invoke-RestMethod with the token in headers for all AzDo API calls.

Usage

./eng/Get-BranchMirrorStatus.ps1
./eng/Get-BranchMirrorStatus.ps1 -SearchDepth 100

Example Output

## Branch Mirror Status

| Repo | Branch | Latest GH Commit | Mirrored? | Details |
|---|---|---|---|---|
| dotnet/sdk | release/8.0.1xx | `2dd56c3` Merging internal commits for release/8.0.1xx (#54667) | ✅ | Direct push (same SHA on AzDo branch) |
| dotnet/sdk | release/8.0.4xx | `57df753` [automated] Merge branch 'release/8.0.1xx' => 'release/8.... | ✅ | Direct push (same SHA on AzDo branch) |
| dotnet/sdk | release/9.0.1xx | `d32f471` Use truncating logger by default for all tests (#54795) | ✅ | Direct push (same SHA on AzDo branch) |
| dotnet/sdk | release/9.0.3xx | `2ceba48` [release/9.0.3xx] Update dependencies from dotnet/arcade ... | ✅ | Direct push (same SHA on AzDo branch) |
| dotnet/installer | release/8.0.1xx | `35e4ab6` Work around missing source-build-reference-packages durin... | ✅ | Direct push (same SHA on AzDo branch) |
| dotnet/installer | release/8.0.4xx | `360defa` Fix empty RPM dependency versions (#20891) | ✅ | Direct push (same SHA on AzDo branch) |

Replace the prompt file with a standalone PowerShell script that checks
whether public GitHub release branches have been mirrored to internal
Azure DevOps repos.

Key fix from original PR #53982: use Invoke-RestMethod with an explicit
token from 'az account get-access-token' instead of 'az rest', which
fails on Windows due to:
1. Token acquisition issues (can't derive resource from AzDo URLs)
2. Unicode encoding errors ('charmap' codec)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 1, 2026 21:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 replaces the .github/prompts/branch-mirror-status.prompt.md prompt (VS/VS Code-specific and deterministic) with a standalone PowerShell script that produces the same “branch mirror status” report by querying GitHub (via gh) and Azure DevOps (via az + Invoke-RestMethod).

Changes:

  • Added eng/Get-BranchMirrorStatus.ps1 to compute and emit a markdown table of mirror status for configured release branches.
  • Removed .github/prompts/branch-mirror-status.prompt.md now that the check is implemented as an executable script.

Reviewed changes

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

File Description
eng/Get-BranchMirrorStatus.ps1 New script that checks latest GitHub commit per release branch and verifies it’s present/mirrored in AzDo, emitting markdown output.
.github/prompts/branch-mirror-status.prompt.md Removed the deterministic prompt file in favor of the standalone script.

Comment thread eng/Get-BranchMirrorStatus.ps1
Comment thread eng/Get-BranchMirrorStatus.ps1
@marcpopMSFT

Copy link
Copy Markdown
Member Author

@lbussell I noticed your other PR went stale and had my local copilot try to fix the scripts. It apparently didn't have access to your branch so created it's own PR. this script works for me.

- Add [ValidateRange(1, MaxValue)] to SearchDepth parameter
- Remove 2>&1 from az token call to avoid stderr corruption
- Add --only-show-errors and .Trim() for clean token capture

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marcpopMSFT marcpopMSFT enabled auto-merge July 1, 2026 22:35
…reCategory: InfrastructureError)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread eng/Get-BranchMirrorStatus.ps1
Comment thread eng/Get-BranchMirrorStatus.ps1
Comment thread eng/Get-BranchMirrorStatus.ps1
Comment thread eng/Get-BranchMirrorStatus.ps1
…I URL

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants