Fix mirror-update-pats corrupting all GitHub mirror URLs

The bash parameter expansion `${var/pat/rep}` treats `\/` in the
replacement as a literal backslash-slash, not an escaped delimiter.
This produced URLs like `https:\/\/eblume:...` instead of
`https://eblume:...`, breaking Forgejo's URL parser (500 on mirror
settings pages) and preventing mirror syncs.

Use prefix stripping (`${var#prefix}`) instead.

All 22 corrupted mirrors have been repaired on indri.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Erich Blume 2026-03-03 11:46:41 -08:00
commit f91b8d0d98

View file

@ -39,7 +39,9 @@ while IFS='|' read -r org repo upstream_url; do
bare_repo="${REPO_BASE}/${org}/${repo}.git"
# Build authenticated URL: https://eblume:<pat>@github.com/...
auth_url="${upstream_url/https:\/\/github.com/https:\/\/eblume:${pat}@github.com}"
# Note: \/ in the replacement part of ${var/pat/rep} is literal backslash-slash,
# not an escaped slash. Use prefix stripping instead.
auth_url="https://eblume:${pat}@github.com${upstream_url#https://github.com}"
if [[ "$DRY_RUN" == "true" ]]; then
echo "[dry-run] ${org}/${repo}: would set origin to authenticated URL"