|
| 1 | +#!/usr/bin/env pwsh |
| 2 | + |
| 3 | +# Finds the latest public and internal release branches in dotnet/dotnet-docker |
| 4 | +# by fetching from GitHub (public) and Azure DevOps (internal) and listing by |
| 5 | +# branch creation date. |
| 6 | + |
| 7 | +function Get-RemoteName { |
| 8 | + param( |
| 9 | + [Parameter(Mandatory = $true)] |
| 10 | + [string] $UrlPattern |
| 11 | + ) |
| 12 | + |
| 13 | + $matchingRemotes = @(git remote | Where-Object { |
| 14 | + $remoteName = $_ |
| 15 | + $remoteUrl = git remote get-url $remoteName 2>$null |
| 16 | + $remoteUrl -match $UrlPattern |
| 17 | + }) |
| 18 | + |
| 19 | + if ($matchingRemotes.Count -eq 0) { |
| 20 | + throw "Unable to find a remote with a URL matching '$UrlPattern'." |
| 21 | + } |
| 22 | + |
| 23 | + if ($matchingRemotes.Count -gt 1) { |
| 24 | + throw "Found multiple remotes with URLs matching '$UrlPattern': $($matchingRemotes -join ', ')." |
| 25 | + } |
| 26 | + |
| 27 | + return $matchingRemotes[0] |
| 28 | +} |
| 29 | + |
| 30 | +# Show basic documentation |
| 31 | +Write-Host "# Release branches" |
| 32 | +Write-Host "Release branches follow the Windows release naming scheme." |
| 33 | +Write-Host "Example: 2026-04B refers to the second week (B) of April 2026." |
| 34 | + |
| 35 | +$gitHubRemote = Get-RemoteName -UrlPattern 'github\.com[:/]dotnet/' |
| 36 | +$dncengRemote = Get-RemoteName -UrlPattern 'dev\.azure\.com/dnceng/' |
| 37 | +$upstreamRemoteUrl = git remote get-url $gitHubRemote |
| 38 | +$dncengRemoteUrl = git remote get-url $dncengRemote |
| 39 | + |
| 40 | +Write-Host "" |
| 41 | +Write-Host "## Repo configuration" |
| 42 | +Write-Host "This repo is configured with the following remotes:" |
| 43 | +Write-Host "" |
| 44 | +Write-Host "Source | Remote Name | Remote URL" |
| 45 | +Write-Host "--- | --- | ---" |
| 46 | +Write-Host "Public | $gitHubRemote | $upstreamRemoteUrl" |
| 47 | +Write-Host "Internal | $dncengRemote | $dncengRemoteUrl" |
| 48 | + |
| 49 | +git fetch $gitHubRemote 2>&1 | Out-Null |
| 50 | +git fetch $dncengRemote 2>&1 | Out-Null |
| 51 | + |
| 52 | +$numberOfBranches = 5 |
| 53 | + |
| 54 | +Write-Host "" |
| 55 | +Write-Host "## ${numberOfBranches} most recent public release branches" |
| 56 | +git branch -r --list "$gitHubRemote/release/*" --sort=-creatordate ` |
| 57 | + | Select-Object -First $numberOfBranches ` |
| 58 | + | ForEach-Object { Write-Host "- $($_.Trim())" } |
| 59 | + |
| 60 | +Write-Host "" |
| 61 | +Write-Host "## ${numberOfBranches} most recent internal release branches" |
| 62 | +git branch -r --list "$dncengRemote/internal/release/*" --sort=-creatordate ` |
| 63 | + | Select-Object -First $numberOfBranches ` |
| 64 | + | ForEach-Object { Write-Host "- $($_.Trim())" } |
0 commit comments