cmd/update.sh: use GitHub API token if available.
Fixes https://github.com/Homebrew/brew/issues/14335
This commit is contained in:
parent
106af03557
commit
f788765876
@ -482,7 +482,7 @@ EOS
|
|||||||
QUIET_ARGS=()
|
QUIET_ARGS=()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# HOMEBREW_CURLRC isn't misspelt here
|
# HOMEBREW_CURLRC is optionally defined in the user environment.
|
||||||
# shellcheck disable=SC2153
|
# shellcheck disable=SC2153
|
||||||
if [[ -z "${HOMEBREW_CURLRC}" ]]
|
if [[ -z "${HOMEBREW_CURLRC}" ]]
|
||||||
then
|
then
|
||||||
@ -491,6 +491,15 @@ EOS
|
|||||||
CURL_DISABLE_CURLRC_ARGS=()
|
CURL_DISABLE_CURLRC_ARGS=()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# HOMEBREW_GITHUB_API_TOKEN is optionally defined in the user environment.
|
||||||
|
# shellcheck disable=SC2153
|
||||||
|
if [[ -n "${HOMEBREW_GITHUB_API_TOKEN}" ]]
|
||||||
|
then
|
||||||
|
CURL_GITHUB_API_ARGS=("--header" "Authorization: token ${HOMEBREW_GITHUB_API_TOKEN}")
|
||||||
|
else
|
||||||
|
CURL_GITHUB_API_ARGS=()
|
||||||
|
fi
|
||||||
|
|
||||||
# only allow one instance of brew update
|
# only allow one instance of brew update
|
||||||
lock update
|
lock update
|
||||||
|
|
||||||
@ -626,10 +635,12 @@ EOS
|
|||||||
UPSTREAM_SHA_HTTP_CODE="$(
|
UPSTREAM_SHA_HTTP_CODE="$(
|
||||||
curl \
|
curl \
|
||||||
"${CURL_DISABLE_CURLRC_ARGS[@]}" \
|
"${CURL_DISABLE_CURLRC_ARGS[@]}" \
|
||||||
|
"${CURL_GITHUB_API_ARGS[@]}" \
|
||||||
--silent --max-time 3 \
|
--silent --max-time 3 \
|
||||||
--location --no-remote-time --output /dev/null --write-out "%{http_code}" \
|
--location --no-remote-time --output /dev/null --write-out "%{http_code}" \
|
||||||
--dump-header "${DIR}/.git/GITHUB_HEADERS" \
|
--dump-header "${DIR}/.git/GITHUB_HEADERS" \
|
||||||
--user-agent "${HOMEBREW_USER_AGENT_CURL}" \
|
--user-agent "${HOMEBREW_USER_AGENT_CURL}" \
|
||||||
|
--header "X-GitHub-Api-Version:2022-11-28" \
|
||||||
--header "Accept: ${GITHUB_API_ACCEPT}" \
|
--header "Accept: ${GITHUB_API_ACCEPT}" \
|
||||||
--header "If-None-Match: \"${GITHUB_API_ETAG}\"" \
|
--header "If-None-Match: \"${GITHUB_API_ETAG}\"" \
|
||||||
"https://api.github.com/repos/${UPSTREAM_REPOSITORY}/${GITHUB_API_ENDPOINT}"
|
"https://api.github.com/repos/${UPSTREAM_REPOSITORY}/${GITHUB_API_ENDPOINT}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user