chore(github): remove kalinamall/papatramp mirror scripts

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-16 11:57:03 +10:00
parent 2956d14d94
commit 619cc9e1ac
4 changed files with 0 additions and 208 deletions
-41
View File
@@ -1,41 +0,0 @@
# 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"
-57
View File
@@ -1,57 +0,0 @@
# 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"
-43
View File
@@ -1,43 +0,0 @@
#!/usr/bin/env bash
# Push main to a mirror remote with host-specific doc URLs, without leaving URL churn on main.
# Usage: push-mirror.sh github|kalinamall|papatramp
set -euo pipefail
TARGET="${1:?usage: push-mirror.sh github|kalinamall|papatramp}"
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
case "$TARGET" in
github) REMOTE=github ;;
kalinamall) REMOTE=kalinamall ;;
papatramp) REMOTE=papatramp ;;
*)
echo "unknown target: $TARGET" >&2
exit 1
;;
esac
if ! git remote get-url "$REMOTE" >/dev/null 2>&1; then
echo "remote not configured: $REMOTE" >&2
exit 1
fi
if ! git diff --quiet || ! git diff --cached --quiet; then
echo "working tree not clean; commit or stash first" >&2
exit 1
fi
BEFORE="$(git rev-parse HEAD)"
bash "$ROOT/scripts/rewrite-git-host-urls.sh" "$TARGET"
if git diff --quiet; then
echo "no URL changes for $TARGET; pushing as-is"
git push "$REMOTE" main
exit 0
fi
git add -A
git commit -m "chore(docs): sync repository URLs for ${TARGET} mirror"
git push "$REMOTE" main
git reset --hard "$BEFORE"
echo "pushed $REMOTE with ${TARGET} URLs; local main reset to $BEFORE"
-67
View File
@@ -1,67 +0,0 @@
#!/usr/bin/env bash
# Rewrite cross-repo URLs in tracked docs/config for the target Git host.
# Usage: rewrite-git-host-urls.sh github|kalinamall|papatramp
set -euo pipefail
TARGET="${1:?usage: rewrite-git-host-urls.sh github|kalinamall|papatramp}"
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
case "$TARGET" in
github)
BASE='https://github.com/PTah'
BLOB_SUFFIX='/blob/main'
;;
kalinamall)
BASE='https://git.kalinamall.ru/PapaTramp'
BLOB_SUFFIX='/src/branch/main'
;;
papatramp)
BASE='https://git.papatramp.ru/PTah'
BLOB_SUFFIX='/src/branch/main'
;;
*)
echo "unknown target: $TARGET" >&2
exit 1
;;
esac
# Order matters: longer patterns first.
PATTERNS=(
's|https://github.com/PTah/\([^)/"'"'"' ]*\)/blob/main/|'"${BASE}"'/\1'"${BLOB_SUFFIX}"'/|g'
's|https://git.kalinamall.ru/PapaTramp/\([^)/"'"'"' ]*\)/src/branch/main/|'"${BASE}"'/\1'"${BLOB_SUFFIX}"'/|g'
's|https://git.papatramp.ru/PTah/\([^)/"'"'"' ]*\)/src/branch/main/|'"${BASE}"'/\1'"${BLOB_SUFFIX}"'/|g'
's|https://github.com/PTah/|'"${BASE}"'/|g'
's|https://git.kalinamall.ru/PapaTramp/|'"${BASE}"'/|g'
's|https://git.papatramp.ru/PTah/|'"${BASE}"'/|g'
's|github.com/PTah/|'"${BASE#https://}"'/|g'
's|git.kalinamall.ru/PapaTramp/|'"${BASE#https://}"'/|g'
's|git.papatramp.ru/PTah/|'"${BASE#https://}"'/|g'
)
FILES=()
while IFS= read -r -d '' f; do
FILES+=("$f")
done < <(git ls-files '*.md' '*.json' '*.service' '*.example' '*.sh' '*.ps1' '*.yml' '*.yaml' 2>/dev/null | tr '\n' '\0')
if [ "${#FILES[@]}" -eq 0 ]; then
echo "no files to rewrite" >&2
exit 0
fi
for f in "${FILES[@]}"; do
[ -f "$f" ] || continue
tmp="$(mktemp)"
cp "$f" "$tmp"
for pat in "${PATTERNS[@]}"; do
sed -i "$pat" "$tmp" 2>/dev/null || sed -i '' "$pat" "$tmp"
done
if ! cmp -s "$f" "$tmp"; then
mv "$tmp" "$f"
echo "updated: $f"
else
rm -f "$tmp"
fi
done
echo "rewrite-git-host-urls: target=$TARGET base=$BASE"