# Push main to a mirror remote with host-specific doc URLs, without leaving URL churn on main. # Usage: .\scripts\Push-Mirror.ps1 github|kalinamall|papatramp param( [Parameter(Mandatory = $true)] [ValidateSet('github', 'kalinamall', 'papatramp')] [string]$Target ) $ErrorActionPreference = 'Stop' $Root = Split-Path -Parent $PSScriptRoot Set-Location $Root $remote = switch ($Target) { 'github' { 'github' } 'kalinamall' { 'kalinamall' } 'papatramp' { 'papatramp' } } git remote get-url $remote 2>$null | Out-Null if ($LASTEXITCODE -ne 0) { throw "remote not configured: $remote" } if ((git status --porcelain -uno)) { throw 'working tree has uncommitted tracked changes; commit or stash first' } $before = (git rev-parse HEAD).Trim() & "$PSScriptRoot\Rewrite-GitHostUrls.ps1" -Target $Target if (-not (git status --porcelain)) { Write-Output "no URL changes for $Target; pushing as-is" git push $remote main exit 0 } git add -A git commit -m "chore(docs): sync repository URLs for ${Target} mirror" git push --force-with-lease $remote main git reset --hard $before Write-Output "pushed $remote with ${Target} URLs; local main reset to $before"