mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Merge pull request #13795 from Rylan12/api-update-improvements
Improve `brew update` with `HOMEBREW_INSTALL_FROM_API`
This commit is contained in:
commit
e689cc07d9
@ -33,7 +33,7 @@ module Homebrew
|
|||||||
if cached_formula_json_file.exist? && !cached_formula_json_file.empty?
|
if cached_formula_json_file.exist? && !cached_formula_json_file.empty?
|
||||||
curl_args.prepend("--time-cond", cached_formula_json_file)
|
curl_args.prepend("--time-cond", cached_formula_json_file)
|
||||||
end
|
end
|
||||||
curl_download(*curl_args, to: HOMEBREW_CACHE_API/"#{formula_api_path}.json", max_time: 5)
|
curl_download(*curl_args, to: cached_formula_json_file, max_time: 5)
|
||||||
|
|
||||||
json_formulae = JSON.parse(cached_formula_json_file.read)
|
json_formulae = JSON.parse(cached_formula_json_file.read)
|
||||||
|
|
||||||
|
@ -547,7 +547,7 @@ EOS
|
|||||||
for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
|
for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
|
||||||
do
|
do
|
||||||
if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]] &&
|
if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]] &&
|
||||||
[[ -n "${HOMEBREW_UPDATE_AUTO}" ]] &&
|
[[ -z "${HOMEBREW_DEVELOPER}" || -n "${HOMEBREW_UPDATE_AUTO}" ]] &&
|
||||||
[[ "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" ]]
|
[[ "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" ]]
|
||||||
then
|
then
|
||||||
continue
|
continue
|
||||||
@ -705,6 +705,7 @@ EOS
|
|||||||
for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
|
for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
|
||||||
do
|
do
|
||||||
if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]] &&
|
if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]] &&
|
||||||
|
[[ -z "${HOMEBREW_DEVELOPER}" || -n "${HOMEBREW_UPDATE_AUTO}" ]] &&
|
||||||
[[ "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" ||
|
[[ "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" ||
|
||||||
"${DIR}" == "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-cask" ]]
|
"${DIR}" == "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-cask" ]]
|
||||||
then
|
then
|
||||||
@ -748,11 +749,11 @@ EOS
|
|||||||
if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]]
|
if [[ -n "${HOMEBREW_INSTALL_FROM_API}" ]]
|
||||||
then
|
then
|
||||||
mkdir -p "${HOMEBREW_CACHE}/api"
|
mkdir -p "${HOMEBREW_CACHE}/api"
|
||||||
# TODO: use --header If-Modified-Since
|
|
||||||
curl \
|
curl \
|
||||||
"${CURL_DISABLE_CURLRC_ARGS[@]}" \
|
"${CURL_DISABLE_CURLRC_ARGS[@]}" \
|
||||||
--fail --compressed --silent --max-time 5 \
|
--fail --compressed --silent --max-time 5 \
|
||||||
--location --remote-time --output "${HOMEBREW_CACHE}/api/formula.json" \
|
--location --remote-time --output "${HOMEBREW_CACHE}/api/formula.json" \
|
||||||
|
--time-cond "${HOMEBREW_CACHE}/api/formula.json" \
|
||||||
--user-agent "${HOMEBREW_USER_AGENT_CURL}" \
|
--user-agent "${HOMEBREW_USER_AGENT_CURL}" \
|
||||||
"https://formulae.brew.sh/api/formula.json"
|
"https://formulae.brew.sh/api/formula.json"
|
||||||
# TODO: we probably want to print an error if this fails.
|
# TODO: we probably want to print an error if this fails.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user