chore(home): mirror from kalinamall (c53704a) with papatramp URLs

This commit is contained in:
2026-07-14 20:43:31 +10:00
commit 6065b163e2
29 changed files with 2548 additions and 0 deletions
+85
View File
@@ -0,0 +1,85 @@
#!/usr/bin/env bash
# Rewrite cross-repo git host URLs in tracked text files.
# Usage: rewrite-git-host-urls.sh github|kalinamall|home|papatramp [root]
set -euo pipefail
TARGET="${1:-}"
ROOT="${2:-$(pwd)}"
if [[ -z "$TARGET" ]]; then
echo "Usage: $0 github|kalinamall|home|papatramp [root]" >&2
exit 2
fi
if [[ "$TARGET" == "home" ]]; then TARGET=papatramp; fi
ROOT="$(cd "$ROOT" && pwd)"
cd "$ROOT"
case "$TARGET" in
github)
BASE='https://github.com/PTah'
BLOB='/blob/main'
SSHTO='https://git.papatramp.ru/PapaTramp/'
;;
kalinamall)
BASE='https://git.kalinamall.ru/PapaTramp'
BLOB='/src/branch/main'
SSHTO='ssh://git@git.papatramp.ru:2222/PapaTramp/'
;;
papatramp)
BASE='https://git.papatramp.ru/PapaTramp'
BLOB='/src/branch/main'
SSHTO='ssh://git@git.papatramp.ru:2222/PapaTramp/'
;;
*)
echo "Unknown target: $TARGET" >&2
exit 2
;;
esac
BASE_HOST="${BASE#https://}"
N=0
export BASE BLOB SSHTO BASE_HOST
rewrite_file() {
local f="$1"
local tmp
tmp="$(mktemp)"
perl -pe '
s#https://github\.com/PTah/([^)/\x27\"\s]+)/blob/main/#$ENV{BASE}/$1$ENV{BLOB}/#g;
s#https://github\.com/PTah/([^)/\x27\"\s]+)/src/branch/main/#$ENV{BASE}/$1$ENV{BLOB}/#g;
s#https://git\.kalinamall\.ru/PapaTramp/([^)/\x27\"\s]+)/blob/main/#$ENV{BASE}/$1$ENV{BLOB}/#g;
s#https://git\.kalinamall\.ru/PapaTramp/([^)/\x27\"\s]+)/src/branch/main/#$ENV{BASE}/$1$ENV{BLOB}/#g;
s#https://git\.papatramp\.ru/PapaTramp/([^)/\x27\"\s]+)/src/branch/main/#$ENV{BASE}/$1$ENV{BLOB}/#g;
s#https://git\.papatramp\.ru/PTah/([^)/\x27\"\s]+)/src/branch/main/#$ENV{BASE}/$1$ENV{BLOB}/#g;
s#https://github\.com/PTah/#$ENV{BASE}/#g;
s#https://git\.kalinamall\.ru/PapaTramp/#$ENV{BASE}/#g;
s#https://git\.papatramp\.ru/PapaTramp/#$ENV{BASE}/#g;
s#https://git\.papatramp\.ru/PTah/#$ENV{BASE}/#g;
s#ssh://git\@git\.kalinamall\.ru:2222/PapaTramp/#$ENV{SSHTO}#g;
s#ssh://git\@git\.papatramp\.ru:2222/PapaTramp/#$ENV{SSHTO}#g;
s#github\.com/PTah/#$ENV{BASE_HOST}/#g;
s#git\.kalinamall\.ru/PapaTramp/#$ENV{BASE_HOST}/#g;
s#git\.papatramp\.ru/PapaTramp/#$ENV{BASE_HOST}/#g;
s#git\.papatramp\.ru/PTah/#$ENV{BASE_HOST}/#g;
' "$f" > "$tmp"
if ! cmp -s "$f" "$tmp"; then
mv "$tmp" "$f"
echo "updated: $f"
N=$((N + 1))
else
rm -f "$tmp"
fi
}
mapfile -t FILES < <(git -C "$ROOT" ls-files '*.md' '*.json' '*.service' '*.example' '*.sh' '*.ps1' '*.yml' '*.yaml' '*.txt' '*.kt' '*.kts' '*.xml' '*.html' '*.css' '*.ts' '*.vue' '*.py' 2>/dev/null || true)
if [[ ${#FILES[@]} -eq 0 ]]; then
mapfile -t FILES < <(find "$ROOT" -type f \( -name '*.md' -o -name '*.ps1' -o -name '*.sh' -o -name '*.yml' -o -name '*.yaml' -o -name '*.json' -o -name '*.txt' \) ! -path '*/.git/*' ! -path '*/node_modules/*' || true)
fi
for f in "${FILES[@]}"; do
[[ -f "$f" ]] || f="$ROOT/$f"
[[ -f "$f" ]] || continue
rewrite_file "$f"
done
echo "Rewrite-GitHostUrls: target=$TARGET base=$BASE files_changed=$N"