#!/bin/bash # Helper script to get Gitea API information from git remote REMOTE=$(git remote get-url origin 2>/dev/null) if [ -z "$REMOTE" ]; then echo "Error: No git remote found" exit 1 fi # Extract host (assuming format: gitea@HOST:repo.git or ssh://gitea@HOST/repo.git) if [[ $REMOTE == *"@"* ]]; then HOST=$(echo "$REMOTE" | sed 's/.*@\([^:]*\).*/\1/') else HOST=$(echo "$REMOTE" | sed 's|.*://\([^/]*\).*|\1|') fi # Extract repo path (owner/repo) REPO=$(echo "$REMOTE" | sed 's/.*:\(.*\)\.git/\1/' | sed 's|.*/\(.*/.*\)|\1|') # Gitea typically runs on port 3000 API_BASE="http://${HOST}:3000/api/v1" echo "GITEA_HOST=${HOST}" echo "GITEA_REPO=${REPO}" echo "GITEA_API_BASE=${API_BASE}"