create_gitea_issue.sh: better data extraction
Uses a simpler, robust GIT,OWNER,REPO extraction
This commit is contained in:
@@ -27,9 +27,16 @@ fi
|
|||||||
# Handle formats: https://gitea.example.com/owner/repo.git or git@gitea.example.com:owner/repo.git
|
# Handle formats: https://gitea.example.com/owner/repo.git or git@gitea.example.com:owner/repo.git
|
||||||
OWNER=""
|
OWNER=""
|
||||||
REPO=""
|
REPO=""
|
||||||
if [[ "$GIT_URL" =~ [:\/]([^\/:]+)\/([^\/\.]+)(\.git)?$ ]]; then
|
GIT=""
|
||||||
OWNER="${BASH_REMATCH[1]}"
|
if echo "$GIT_URL" | grep -q "^http"; then
|
||||||
REPO="${BASH_REMATCH[2]}"
|
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
|
fi
|
||||||
if [[ -z "$OWNER" || -z "$REPO" ]]; then
|
if [[ -z "$OWNER" || -z "$REPO" ]]; then
|
||||||
echo "[ERROR] Could not determine owner/repo from GIT_URL=$GIT_URL"
|
echo "[ERROR] Could not determine owner/repo from GIT_URL=$GIT_URL"
|
||||||
|
|||||||
Reference in New Issue
Block a user