create_gitea_issue.sh: better data extraction

Uses a simpler, robust GIT,OWNER,REPO extraction
This commit is contained in:
Karsten Jeppesen
2026-04-08 20:11:34 +02:00
parent 902ac28271
commit 02b2093ca4

View File

@@ -27,9 +27,16 @@ fi
# Handle formats: https://gitea.example.com/owner/repo.git or git@gitea.example.com:owner/repo.git
OWNER=""
REPO=""
if [[ "$GIT_URL" =~ [:\/]([^\/:]+)\/([^\/\.]+)(\.git)?$ ]]; then
OWNER="${BASH_REMATCH[1]}"
REPO="${BASH_REMATCH[2]}"
GIT=""
if echo "$GIT_URL" | grep -q "^http"; then
GIT=$(echo "$GIT_URL" | cut -f 3 -d '/')
OWNER=$(echo "$GIT_URL" | cut -f 4 -d '/')
REPO=$(echo "$GIT_URL" | cut -f 5 -d '/' | xargs -- basename -s .git)
fi
if echo "$GIT_URL" | grep -q "^git@"; then
GIT=$(echo "$GIT_URL" | cut -f 2 -d '@' | cut -f 1 -d ':')
OWNER=$(echo "$GIT_URL" | cut -f 2 -d ':' | cut -f 1 -d '/')
REPO=$(echo "$GIT_URL" | cut -f 2 -d '/' | xargs -- basename -s .git)
fi
if [[ -z "$OWNER" || -z "$REPO" ]]; then
echo "[ERROR] Could not determine owner/repo from GIT_URL=$GIT_URL"