updated gitlab_api.sh

pull/2/head
Hari Sekhon 4 years ago
parent e97668664e
commit a267c3ed50

@ -90,10 +90,6 @@ url_base="https://gitlab.com/api/v4"
CURL_OPTS="-sS --fail --connect-timeout 3 ${CURL_OPTS:-}"
if [ -z "${GITLAB_TOKEN:-}" ]; then
GITLAB_TOKEN="$(git remote -v 2>/dev/null | awk '/https:\/\/.+@gitlab\.com/{print $2; exit}' | sed 's|https://||;s/@.*//;s/.*://' || :)"
fi
help_usage "$@"
min_args 1 "$@"
@ -114,6 +110,14 @@ if [ -z "${GITLAB_USER:-}" ]; then
fi
fi
if [ -z "${GITLAB_TOKEN:-}" ]; then
GITLAB_TOKEN="$(git remote -v 2>/dev/null | awk '/https:\/\/.+@gitlab\.com/{print $2; exit}' | sed 's|https://||;s/@.*//;s/.*://' || :)"
fi
if [ -z "$GITLAB_TOKEN" ]; then
usage "GITLAB_TOKEN not defined and could not infer from local repo"
fi
project="$(git_repo 2>/dev/null || :)"
repo="$(sed 's/.*\///' <<< "$project")"
project="${project//\//%2F}" # cheap url encode slash

Loading…
Cancel
Save