|
| 1 | +# delete-me-update-all-integration-branches.ps1 |
| 2 | +# Updates ALL integration branches from their component branches. |
| 3 | +# Run from any branch -- it will stash changes, update each integration branch, then return. |
| 4 | + |
| 5 | +$ErrorActionPreference = 'Stop' |
| 6 | + |
| 7 | +$originalBranch = git rev-parse --abbrev-ref HEAD |
| 8 | +$stashed = $false |
| 9 | + |
| 10 | +# Stash any uncommitted changes |
| 11 | +$status = git status --porcelain |
| 12 | +if ($status) { |
| 13 | + Write-Host "Stashing uncommitted changes..." -ForegroundColor Cyan |
| 14 | + git stash push -m "auto-stash before integration branch update" |
| 15 | + $stashed = $true |
| 16 | +} |
| 17 | + |
| 18 | +Write-Host "Fetching all branches from origin..." -ForegroundColor Cyan |
| 19 | +git fetch origin |
| 20 | + |
| 21 | +$integrationBranches = @( |
| 22 | + @{ |
| 23 | + Name = 'release/next-gen' |
| 24 | + Branches = @( |
| 25 | + 'feature/test-workflow-engine' |
| 26 | + 'feature/hot-runner-protocol' |
| 27 | + 'feature/generic-artifact-system' |
| 28 | + 'feature/incremental-sync-protocol' |
| 29 | + 'feature/community-plugin-validation' |
| 30 | + 'feature/cli-support' |
| 31 | + ) |
| 32 | + } |
| 33 | + @{ |
| 34 | + Name = 'release/lts-2.0.0' |
| 35 | + Branches = @( |
| 36 | + # Infrastructure |
| 37 | + 'feature/orchestrator-enterprise-support' |
| 38 | + 'feature/cloud-run-azure-providers' |
| 39 | + 'feature/provider-load-balancing' |
| 40 | + 'feature/orchestrator-unit-tests' |
| 41 | + 'fix/secure-git-token-usage' |
| 42 | + 'feature/premade-secret-sources' |
| 43 | + 'feature/ci-platform-providers' |
| 44 | + 'feature/build-reliability' |
| 45 | + 'ci/orchestrator-integrity-speedup' |
| 46 | + # Next-gen |
| 47 | + 'feature/test-workflow-engine' |
| 48 | + 'feature/hot-runner-protocol' |
| 49 | + 'feature/generic-artifact-system' |
| 50 | + 'feature/incremental-sync-protocol' |
| 51 | + 'feature/community-plugin-validation' |
| 52 | + 'feature/cli-support' |
| 53 | + ) |
| 54 | + } |
| 55 | +) |
| 56 | + |
| 57 | +foreach ($integration in $integrationBranches) { |
| 58 | + $name = $integration.Name |
| 59 | + Write-Host "`n========================================" -ForegroundColor Cyan |
| 60 | + Write-Host "Updating $name" -ForegroundColor Cyan |
| 61 | + Write-Host "========================================" -ForegroundColor Cyan |
| 62 | + |
| 63 | + # Check if branch exists locally |
| 64 | + $exists = git branch --list $name |
| 65 | + if (-not $exists) { |
| 66 | + Write-Host "Creating local branch from origin/$name..." -ForegroundColor Yellow |
| 67 | + git checkout -b $name "origin/$name" |
| 68 | + } else { |
| 69 | + git checkout $name |
| 70 | + git pull origin $name --ff-only 2>$null |
| 71 | + if ($LASTEXITCODE -ne 0) { |
| 72 | + git pull origin $name --no-edit |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + $failed = @() |
| 77 | + foreach ($branch in $integration.Branches) { |
| 78 | + $remoteBranch = "origin/$branch" |
| 79 | + # Check if remote branch exists |
| 80 | + $refExists = git rev-parse --verify $remoteBranch 2>$null |
| 81 | + if ($LASTEXITCODE -ne 0) { |
| 82 | + Write-Host " Skipping $branch (not found on remote)" -ForegroundColor DarkGray |
| 83 | + continue |
| 84 | + } |
| 85 | + |
| 86 | + # Check if already merged |
| 87 | + $mergeBase = git merge-base HEAD $remoteBranch 2>$null |
| 88 | + $remoteHead = git rev-parse $remoteBranch 2>$null |
| 89 | + if ($mergeBase -eq $remoteHead) { |
| 90 | + Write-Host " $branch - already up to date" -ForegroundColor DarkGray |
| 91 | + continue |
| 92 | + } |
| 93 | + |
| 94 | + Write-Host " Merging $branch..." -ForegroundColor Yellow |
| 95 | + $result = git merge $remoteBranch --no-edit 2>&1 |
| 96 | + if ($LASTEXITCODE -ne 0) { |
| 97 | + Write-Host " CONFLICT - skipped (resolve manually)" -ForegroundColor Red |
| 98 | + $failed += $branch |
| 99 | + git merge --abort |
| 100 | + } else { |
| 101 | + Write-Host " OK" -ForegroundColor Green |
| 102 | + } |
| 103 | + } |
| 104 | + |
| 105 | + if ($failed.Count -gt 0) { |
| 106 | + Write-Host "`n Conflicts in:" -ForegroundColor Red |
| 107 | + $failed | ForEach-Object { Write-Host " - $_" -ForegroundColor Red } |
| 108 | + } |
| 109 | + |
| 110 | + # Push |
| 111 | + Write-Host " Pushing $name to origin..." -ForegroundColor Cyan |
| 112 | + git push origin $name |
| 113 | +} |
| 114 | + |
| 115 | +# Return to original branch |
| 116 | +Write-Host "`nReturning to $originalBranch..." -ForegroundColor Cyan |
| 117 | +git checkout $originalBranch |
| 118 | + |
| 119 | +if ($stashed) { |
| 120 | + Write-Host "Restoring stashed changes..." -ForegroundColor Cyan |
| 121 | + git stash pop |
| 122 | +} |
| 123 | + |
| 124 | +Write-Host "`nDone!" -ForegroundColor Green |
0 commit comments