From e73c86140d0741ebbf40e9e221c7d04bbc73c7b9 Mon Sep 17 00:00:00 2001 From: PTah Date: Tue, 16 Jun 2026 11:36:52 +1000 Subject: [PATCH] chore(docs): GitHub repo URL in README, add mirror URL scripts Co-authored-by: Cursor --- .gitignore | 2 ++ README.md | 3 +- scripts/Push-Mirror.ps1 | 41 ++++++++++++++++++++++++ scripts/Rewrite-GitHostUrls.ps1 | 57 +++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 scripts/Push-Mirror.ps1 create mode 100644 scripts/Rewrite-GitHostUrls.ps1 diff --git a/.gitignore b/.gitignore index e359de2..9d68e9f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ # Workspace bootstrap — локальные секреты **/workspace.local.env + +.cursor/ diff --git a/README.md b/README.md index 70addb2..0a9c849 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,7 @@ TLS: HAProxy на **443** в режиме **TCP + SNI**, **не терминир Доступ снаружи по allowlist: **Git** и **веб-SAC** — `git-sac-allowed`; **RDS** — `rds-allowed` (RU ipdeny + static); **1С** — `1c-allowed`; **Zabbix** (HTTP) — `zabbix-allowed`; **Synology** (`heap`, `exchange`) — `syno-allowed`. **Seaca** — **`sac-api.kalinamall.ru`** без IP-фильтра. -**Основной репозиторий:** [git.kalinamall.ru/PapaTramp/reverse-proxy](https://git.kalinamall.ru/PapaTramp/reverse-proxy) -**Резерв (без секретов):** [github.com/PTah/reverse-proxy](https://github.com/PTah/reverse-proxy) — см. [политику репозиториев](docs/repo-policy.md) +Репозиторий: [https://github.com/PTah/reverse-proxy](https://github.com/PTah/reverse-proxy) ## Соответствие имён и адресов diff --git a/scripts/Push-Mirror.ps1 b/scripts/Push-Mirror.ps1 new file mode 100644 index 0000000..4602a60 --- /dev/null +++ b/scripts/Push-Mirror.ps1 @@ -0,0 +1,41 @@ +# 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)) { + throw 'working tree not clean; 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 $remote main +git reset --hard $before +Write-Output "pushed $remote with ${Target} URLs; local main reset to $before" diff --git a/scripts/Rewrite-GitHostUrls.ps1 b/scripts/Rewrite-GitHostUrls.ps1 new file mode 100644 index 0000000..87a40f5 --- /dev/null +++ b/scripts/Rewrite-GitHostUrls.ps1 @@ -0,0 +1,57 @@ +# Rewrite cross-repo URLs in tracked docs/config for the target Git host. +# Usage: .\scripts\Rewrite-GitHostUrls.ps1 github|kalinamall|papatramp +param( + [Parameter(Mandatory = $true)] + [ValidateSet('github', 'kalinamall', 'papatramp')] + [string]$Target +) + +$ErrorActionPreference = 'Stop' +$Root = Split-Path -Parent $PSScriptRoot +Set-Location $Root + +switch ($Target) { + 'github' { + $Base = 'https://github.com/PTah' + $BlobSuffix = '/blob/main' + } + 'kalinamall' { + $Base = 'https://git.kalinamall.ru/PapaTramp' + $BlobSuffix = '/src/branch/main' + } + 'papatramp' { + $Base = 'https://git.papatramp.ru/PTah' + $BlobSuffix = '/src/branch/main' + } +} + +$BaseHost = $Base -replace '^https://', '' + +$patterns = @( + @{ From = 'https://github.com/PTah/([^)/''"\s]+)/blob/main/'; To = "$Base/`$1$BlobSuffix/" } + @{ From = 'https://git.kalinamall.ru/PapaTramp/([^)/''"\s]+)/src/branch/main/'; To = "$Base/`$1$BlobSuffix/" } + @{ From = 'https://git.papatramp.ru/PTah/([^)/''"\s]+)/src/branch/main/'; To = "$Base/`$1$BlobSuffix/" } + @{ From = 'https://github.com/PTah/'; To = "$Base/" } + @{ From = 'https://git.kalinamall.ru/PapaTramp/'; To = "$Base/" } + @{ From = 'https://git.papatramp.ru/PTah/'; To = "$Base/" } + @{ From = 'github.com/PTah/'; To = "$BaseHost/" } + @{ From = 'git.kalinamall.ru/PapaTramp/'; To = "$BaseHost/" } + @{ From = 'git.papatramp.ru/PTah/'; To = "$BaseHost/" } +) + +$extensions = @('*.md', '*.json', '*.service', '*.example', '*.sh', '*.ps1', '*.yml', '*.yaml') +$files = git ls-files $extensions 2>$null | Where-Object { $_ -and (Test-Path $_) } + +foreach ($file in $files) { + $content = [System.IO.File]::ReadAllText((Join-Path $Root $file)) + $updated = $content + foreach ($p in $patterns) { + $updated = [regex]::Replace($updated, $p.From, $p.To) + } + if ($updated -ne $content) { + [System.IO.File]::WriteAllText((Join-Path $Root $file), $updated, [System.Text.UTF8Encoding]::new($false)) + Write-Output "updated: $file" + } +} + +Write-Output "Rewrite-GitHostUrls: target=$Target base=$Base"