From 57560cf32c036bbd8a7ebf3196cfe49fbada7d8d Mon Sep 17 00:00:00 2001 From: "termux-actions[bot]" Date: Wed, 30 Mar 2022 07:38:30 +0000 Subject: [PATCH] Update repo --- .../updates/api/termux_github_api_get_tag.sh | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/scripts/updates/api/termux_github_api_get_tag.sh b/scripts/updates/api/termux_github_api_get_tag.sh index 252f35c4aa..9a36ea8fbd 100644 --- a/scripts/updates/api/termux_github_api_get_tag.sh +++ b/scripts/updates/api/termux_github_api_get_tag.sh @@ -31,14 +31,22 @@ termux_github_api_get_tag() { local jq_filter local api_url="https://api.github.com" - local -a extra_curl_opts + local -a curl_opts=( + --silent + --location + --retry 10 + --retry-delay 1 + -H "Authorization: token ${GITHUB_TOKEN}" + -H "Accept: application/vnd.github.v3+json" + --write-out '|%{http_code}' + ) if [[ "${TAG_TYPE}" == "newest-tag" ]]; then api_url="${api_url}/graphql" jq_filter='.data.repository.refs.edges[0].node.name' - extra_curl_opts=( - "-X POST" - "-d $( + curl_opts+=(-X POST) + curl_opts+=( + -d "$( cat <<-EOF | tr '\n' ' ' { "query": "query { @@ -71,16 +79,7 @@ termux_github_api_get_tag() { fi local response - # shellcheck disable=SC2086 # we need expansion of ${extra_curl_opts[0]} - response="$( - curl --silent --location --retry 10 --retry-delay 1 \ - -H "Authorization: token ${GITHUB_TOKEN}" \ - -H "Accept: application/vnd.github.v3+json" \ - --write-out '|%{http_code}' \ - ${extra_curl_opts[0]:-} \ - "${extra_curl_opts[1]:-}" \ - "${api_url}" - )" + response="$(curl "${curl_opts[@]}" "${api_url}")" local http_code http_code="${response##*|}" @@ -89,8 +88,8 @@ termux_github_api_get_tag() { local tag_name if [[ "${http_code}" == "200" ]]; then - if jq --exit-status --raw-output "${jq_filter}" <<<"${response:4}" >/dev/null; then - tag_name="$(jq --exit-status --raw-output "${jq_filter}" <<<"${response:4}")" + if jq --exit-status --raw-output "${jq_filter}" <<<"${response}" >/dev/null; then + tag_name="$(jq --exit-status --raw-output "${jq_filter}" <<<"${response}")" else termux_error_exit "ERROR: Failed to parse tag name from: '${response}'" fi