From d57f191ded71bb864a8f8e8dfb1405e8334d4cab Mon Sep 17 00:00:00 2001 From: Jiri Uhlir Date: Fri, 12 Jun 2026 12:18:29 +0200 Subject: [PATCH] Fix Gitea push URL token injection for HTTPS --- scripts/new-dotnet-api-app.sh | 9 ++++++++- scripts/new-dotnet-worker-app.sh | 9 ++++++++- scripts/new-nodejs-ts-app.sh | 9 ++++++++- scripts/new-python-app.sh | 9 ++++++++- scripts/new-static-site-app.sh | 9 ++++++++- 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/scripts/new-dotnet-api-app.sh b/scripts/new-dotnet-api-app.sh index 99613d1..897c307 100755 --- a/scripts/new-dotnet-api-app.sh +++ b/scripts/new-dotnet-api-app.sh @@ -112,7 +112,14 @@ curl -sS -X POST "$GITEA_URL/api/v1/orgs/$GITEA_ORG/repos" \ -H "Content-Type: application/json" \ -d "{\"name\":\"$APP_ID\",\"private\":false,\"auto_init\":false}" >/dev/null || true -GITEA_PUSH_URL="${GITEA_URL/http:\/\//http:\/\/${GITEA_TOKEN}@}" +if [[ "$GITEA_URL" == http://* ]]; then + GITEA_PUSH_URL="${GITEA_URL/http:\/\//http:\/\/${GITEA_TOKEN}@}" +elif [[ "$GITEA_URL" == https://* ]]; then + GITEA_PUSH_URL="${GITEA_URL/https:\/\//https:\/\/${GITEA_TOKEN}@}" +else + echo "Unsupported GITEA_URL: $GITEA_URL" + exit 1 +fi git remote remove origin 2>/dev/null || true git remote add origin "$GITEA_PUSH_URL/$GITEA_ORG/$APP_ID.git" git push -u origin main diff --git a/scripts/new-dotnet-worker-app.sh b/scripts/new-dotnet-worker-app.sh index e52100f..fae09c2 100755 --- a/scripts/new-dotnet-worker-app.sh +++ b/scripts/new-dotnet-worker-app.sh @@ -162,7 +162,14 @@ curl -sS -X POST "$GITEA_URL/api/v1/orgs/$GITEA_ORG/repos" \ -H "Content-Type: application/json" \ -d "{\"name\":\"$APP_ID\",\"private\":false,\"auto_init\":false}" >/dev/null || true -GITEA_PUSH_URL="${GITEA_URL/http:\/\//http:\/\/${GITEA_TOKEN}@}" +if [[ "$GITEA_URL" == http://* ]]; then + GITEA_PUSH_URL="${GITEA_URL/http:\/\//http:\/\/${GITEA_TOKEN}@}" +elif [[ "$GITEA_URL" == https://* ]]; then + GITEA_PUSH_URL="${GITEA_URL/https:\/\//https:\/\/${GITEA_TOKEN}@}" +else + echo "Unsupported GITEA_URL: $GITEA_URL" + exit 1 +fi git remote remove origin 2>/dev/null || true git remote add origin "$GITEA_PUSH_URL/$GITEA_ORG/$APP_ID.git" diff --git a/scripts/new-nodejs-ts-app.sh b/scripts/new-nodejs-ts-app.sh index a970c0b..8d331a0 100755 --- a/scripts/new-nodejs-ts-app.sh +++ b/scripts/new-nodejs-ts-app.sh @@ -133,7 +133,14 @@ curl -sS -X POST "$GITEA_URL/api/v1/orgs/$GITEA_ORG/repos" \ -H "Content-Type: application/json" \ -d "{\"name\":\"$APP_ID\",\"private\":false,\"auto_init\":false}" >/dev/null || true -GITEA_PUSH_URL="${GITEA_URL/http:\/\//http:\/\/${GITEA_TOKEN}@}" +if [[ "$GITEA_URL" == http://* ]]; then + GITEA_PUSH_URL="${GITEA_URL/http:\/\//http:\/\/${GITEA_TOKEN}@}" +elif [[ "$GITEA_URL" == https://* ]]; then + GITEA_PUSH_URL="${GITEA_URL/https:\/\//https:\/\/${GITEA_TOKEN}@}" +else + echo "Unsupported GITEA_URL: $GITEA_URL" + exit 1 +fi git remote remove origin 2>/dev/null || true git remote add origin "$GITEA_PUSH_URL/$GITEA_ORG/$APP_ID.git" git push -u origin main diff --git a/scripts/new-python-app.sh b/scripts/new-python-app.sh index 652f971..3f1a306 100755 --- a/scripts/new-python-app.sh +++ b/scripts/new-python-app.sh @@ -100,7 +100,14 @@ git config user.name "AppFactory Bot" git config user.email "appfactory@local" git branch -M main -GITEA_PUSH_URL="${GITEA_URL/http:\/\//http:\/\/${GITEA_TOKEN}@}" +if [[ "$GITEA_URL" == http://* ]]; then + GITEA_PUSH_URL="${GITEA_URL/http:\/\//http:\/\/${GITEA_TOKEN}@}" +elif [[ "$GITEA_URL" == https://* ]]; then + GITEA_PUSH_URL="${GITEA_URL/https:\/\//https:\/\/${GITEA_TOKEN}@}" +else + echo "Unsupported GITEA_URL: $GITEA_URL" + exit 1 +fi git remote add origin "$GITEA_PUSH_URL/$GITEA_ORG/$APP_ID.git" git add . diff --git a/scripts/new-static-site-app.sh b/scripts/new-static-site-app.sh index cdd79f5..06c7cc2 100755 --- a/scripts/new-static-site-app.sh +++ b/scripts/new-static-site-app.sh @@ -88,7 +88,14 @@ curl -sS -X POST "$GITEA_URL/api/v1/orgs/$GITEA_ORG/repos" \ -H "Content-Type: application/json" \ -d "{\"name\":\"$APP_ID\",\"private\":false,\"auto_init\":false}" >/dev/null || true -GITEA_PUSH_URL="${GITEA_URL/http:\/\//http:\/\/${GITEA_TOKEN}@}" +if [[ "$GITEA_URL" == http://* ]]; then + GITEA_PUSH_URL="${GITEA_URL/http:\/\//http:\/\/${GITEA_TOKEN}@}" +elif [[ "$GITEA_URL" == https://* ]]; then + GITEA_PUSH_URL="${GITEA_URL/https:\/\//https:\/\/${GITEA_TOKEN}@}" +else + echo "Unsupported GITEA_URL: $GITEA_URL" + exit 1 +fi git remote remove origin 2>/dev/null || true git remote add origin "$GITEA_PUSH_URL/$GITEA_ORG/$APP_ID.git" git push -u origin main