bootstrap.sh: preserve URL scheme in credentials file

git credential helper does exact prefix match including scheme. Hardcoding
https:// breaks for in-LAN clones using http://192.168.8.121:3000 (which
LXC 105 needs because its DNS doesn't have the split-horizon override).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
root
2026-05-20 16:30:17 +02:00
parent 385deb6dec
commit de6f8bec42

View File

@@ -56,11 +56,12 @@ configure_gitea_creds() {
local creds_file=$creds_dir/git-credentials
mkdir -p "$creds_dir"
chmod 700 "$creds_dir"
# Format the credential URL: protocol://user:token@host
# Extract host from REPO_HTTPS for the credential line.
local host
# Format the credential URL: <scheme>://user:token@host (scheme must match
# the actual REPO_HTTPS — git's credential helper does exact prefix match).
local proto host
proto=$(echo "$REPO_HTTPS" | sed -E 's|^(https?)://.*|\1|')
host=$(echo "$REPO_HTTPS" | sed -E 's|^https?://([^/]+).*|\1|')
printf 'https://%s:%s@%s\n' "$GITEA_USER" "$GITEA_TOKEN" "$host" > "$creds_file"
printf '%s://%s:%s@%s\n' "$proto" "$GITEA_USER" "$GITEA_TOKEN" "$host" > "$creds_file"
chmod 600 "$creds_file"
# Point git at this store globally for root (so future pulls work too).
git config --global credential.helper "store --file=$creds_file"