This repository has been archived on 2026-07-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
the-custodian/tools/patch-forgejo-remote-urls.sh
codex af49c053f1 finish(CUST-WP-0054): workstation independence engineering closeout
Complete T04–T08: bulk Forgejo remote_url migration for all registered
repos, phase 5 stabilization tooling, dev-hub beachhead artifacts, and
phoenix drill runbook. Archive workplan with T09/T10 as operator gates.
2026-07-08 11:42:49 +02:00

64 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Patch State Hub managed_repos.remote_url from gitea-remote to forgejo-remote.
# Usage: patch-forgejo-remote-urls.sh slug [slug ...]
# patch-forgejo-remote-urls.sh --tier-25
set -euo pipefail
API_BASE="${API_BASE:-http://127.0.0.1:8000}"
ORG="${FORGEJO_ORG:-coulomb}"
TIER_25=(
railiance-enablement
railiance-infra
railiance-apps
railiance-platform
railiance-cluster
glas-harness
key-cape
)
if [[ "${1:-}" == "--tier-25" ]]; then
set -- "${TIER_25[@]}"
fi
if [[ "${1:-}" == "--all-gitea" ]]; then
mapfile -t SLUGS < <(curl -fsS "${API_BASE}/repos/" | python3 -c "
import json,sys
for r in json.load(sys.stdin):
url = r.get('remote_url') or ''
if 'gitea-remote' in url or 'gitea.coulomb.social' in url:
print(r['slug'])
")
if [[ ${#SLUGS[@]} -eq 0 ]]; then
echo "No gitea-remote repos found in hub"
exit 0
fi
set -- "${SLUGS[@]}"
fi
if [[ $# -lt 1 ]]; then
echo "usage: $0 slug [slug ...] | --tier-25 | --all-gitea" >&2
exit 1
fi
for slug in "$@"; do
new_url="forgejo-remote:${ORG}/${slug}.git"
http=$(curl -sS -o /tmp/repo-get.json -w '%{http_code}' "${API_BASE}/repos/${slug}")
if [[ "${http}" == "404" ]]; then
echo "SKIP ${slug} (not registered in State Hub)"
continue
fi
if [[ "${http}" != "200" ]]; then
echo "FAIL ${slug} GET http=${http}" >&2
exit 1
fi
current=$(python3 -c "import json; print(json.load(open('/tmp/repo-get.json')).get('remote_url') or '')")
if [[ "${current}" == "${new_url}" ]]; then
echo "OK ${slug} (unchanged)"
continue
fi
curl -fsS -X PATCH "${API_BASE}/repos/${slug}" \
-H "Content-Type: application/json" \
-d "{\"remote_url\": \"${new_url}\"}" >/dev/null
echo "PATCH ${slug}: ${current:-<empty>} -> ${new_url}"
done