|
| 1 | +# Make prerelease the new main, and rename current main to main_deprecated. |
| 2 | +# |
| 3 | +# Run from repo root in PowerShell. Requires: no uncommitted changes, branches main + prerelease exist. |
| 4 | +# After running, push with: git push origin main_deprecated; git push origin main --force |
| 5 | + |
| 6 | +$ErrorActionPreference = "Stop" |
| 7 | + |
| 8 | +Write-Host "=== Make prerelease the main branch ===" -ForegroundColor Cyan |
| 9 | +Write-Host "" |
| 10 | + |
| 11 | +# 1. Fetch latest |
| 12 | +git fetch origin |
| 13 | +if ($LASTEXITCODE -ne 0) { exit 1 } |
| 14 | + |
| 15 | +# 2. Ensure we have origin/main and origin/prerelease |
| 16 | +$null = git rev-parse --verify origin/main 2>$null |
| 17 | +if ($LASTEXITCODE -ne 0) { |
| 18 | + Write-Host "Error: origin/main not found. Run: git fetch origin" -ForegroundColor Red |
| 19 | + exit 1 |
| 20 | +} |
| 21 | +$null = git rev-parse --verify origin/prerelease 2>$null |
| 22 | +if ($LASTEXITCODE -ne 0) { |
| 23 | + Write-Host "Error: origin/prerelease not found. Run: git fetch origin" -ForegroundColor Red |
| 24 | + exit 1 |
| 25 | +} |
| 26 | + |
| 27 | +# 3. Switch to main and update |
| 28 | +git checkout main |
| 29 | +git pull origin main 2>$null |
| 30 | + |
| 31 | +# 4. Rename current local main to main_deprecated |
| 32 | +git branch -m main main_deprecated |
| 33 | +Write-Host "Renamed local branch main -> main_deprecated" -ForegroundColor Green |
| 34 | + |
| 35 | +# 5. Create new local main from origin/prerelease |
| 36 | +git checkout -b main origin/prerelease |
| 37 | +Write-Host "Created new local branch main from origin/prerelease" -ForegroundColor Green |
| 38 | + |
| 39 | +# 6. Summary |
| 40 | +Write-Host "" |
| 41 | +Write-Host "Done. Next steps (run these to update the remote):" -ForegroundColor Yellow |
| 42 | +Write-Host " 1. Push the deprecated main: git push origin main_deprecated" |
| 43 | +Write-Host " 2. Force-push the new main: git push origin main --force" |
| 44 | +Write-Host " 3. (Optional) Delete remote prerelease: git push origin --delete prerelease" |
| 45 | +Write-Host "" |
0 commit comments