Obsłuż adres SSH w skrypcie wydania Androida
This commit is contained in:
@@ -138,6 +138,14 @@ if [[ "$sanitized_remote" =~ ^(https?)://([^/]+)/(.+)$ ]]; then
|
||||
detected_protocol="${BASH_REMATCH[1]}"
|
||||
detected_host="${BASH_REMATCH[2]}"
|
||||
detected_repository="${BASH_REMATCH[3]%.git}"
|
||||
elif [[ "$remote_url" =~ ^ssh://([^/@]+@)?([^/:]+)(:[0-9]+)?/(.+)$ ]]; then
|
||||
detected_protocol="https"
|
||||
detected_host="${BASH_REMATCH[2]}"
|
||||
detected_repository="${BASH_REMATCH[4]%.git}"
|
||||
elif [[ "$remote_url" =~ ^([^/@:]+@)?([^/:]+):(.+)$ ]]; then
|
||||
detected_protocol="https"
|
||||
detected_host="${BASH_REMATCH[2]}"
|
||||
detected_repository="${BASH_REMATCH[3]%.git}"
|
||||
else
|
||||
detected_protocol="https"
|
||||
detected_host=""
|
||||
@@ -147,14 +155,20 @@ fi
|
||||
gitea_base_url="${GITEA_BASE_URL:-${detected_protocol}://${detected_host}}"
|
||||
gitea_repository="${GITEA_REPOSITORY:-$detected_repository}"
|
||||
gitea_base_url="${gitea_base_url%/}"
|
||||
[[ "$gitea_base_url" =~ ^https?://[^/]+$ ]] || { echo "Ustaw poprawne GITEA_BASE_URL." >&2; exit 1; }
|
||||
if [[ "$gitea_base_url" =~ ^(https?)://([^/]+)$ ]]; then
|
||||
gitea_api_protocol="${BASH_REMATCH[1]}"
|
||||
gitea_api_host="${BASH_REMATCH[2]}"
|
||||
else
|
||||
echo "Ustaw poprawne GITEA_BASE_URL." >&2
|
||||
exit 1
|
||||
fi
|
||||
[[ "$gitea_repository" =~ ^[^/]+/[^/]+$ ]] || { echo "Ustaw poprawne GITEA_REPOSITORY=owner/repository." >&2; exit 1; }
|
||||
|
||||
auth_args=()
|
||||
if [[ -n "${GITEA_TOKEN:-}" ]]; then
|
||||
auth_args=(-H "Authorization: token $GITEA_TOKEN")
|
||||
else
|
||||
credential="$(printf 'protocol=%s\nhost=%s\n\n' "$detected_protocol" "$detected_host" | git credential fill)"
|
||||
credential="$(printf 'protocol=%s\nhost=%s\n\n' "$gitea_api_protocol" "$gitea_api_host" | git credential fill)"
|
||||
gitea_username="$(printf '%s\n' "$credential" | sed -n 's/^username=//p')"
|
||||
gitea_password="$(printf '%s\n' "$credential" | sed -n 's/^password=//p')"
|
||||
[[ -n "$gitea_username" && -n "$gitea_password" ]] || {
|
||||
|
||||
Reference in New Issue
Block a user