From ef49b5a537807d8c1328beea964694814ca413f6 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 29 Apr 2024 17:42:51 +0100 Subject: [PATCH] brew.sh: auto-update 3rd-party taps more often. When doing an `install`, `outdated` or `upgrade` and referring to a formula or cask in a specific tap: you probably want to get the latest version of that formula/cask more often than the default 1 or 24 hours. Let's check for arguments for these commands that look appropriate and auto-update every 5 minutes in that case. --- Library/Homebrew/brew.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index a00510b400..90a5a3d333 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -278,9 +278,30 @@ auto-update() { then export HOMEBREW_AUTO_UPDATING="1" + # Look for commands that may be referring to a formula/cask in a specific + # 3rd-party tap so they can be auto-updated more often (as they do not get + # their data from the API). + AUTO_UPDATE_TAP_COMMANDS=( + install + outdated + upgrade + ) + if check-array-membership "${HOMEBREW_COMMAND}" "${AUTO_UPDATE_TAP_COMMANDS[@]}" + then + for arg in "$@" + do + if [[ "${arg}" == */*/* ]] && [[ "${arg}" != Homebrew/* ]] && [[ "${arg}" != homebrew/* ]] + then + + HOMEBREW_AUTO_UPDATE_TAP="1" + break + fi + done + fi + if [[ -z "${HOMEBREW_AUTO_UPDATE_SECS}" ]] then - if [[ -n "${HOMEBREW_NO_INSTALL_FROM_API}" ]] + if [[ -n "${HOMEBREW_NO_INSTALL_FROM_API}" || -n "${HOMEBREW_AUTO_UPDATE_TAP}" ]] then # 5 minutes HOMEBREW_AUTO_UPDATE_SECS="300" @@ -326,6 +347,7 @@ auto-update() { brew update --auto-update unset HOMEBREW_AUTO_UPDATING + unset HOMEBREW_AUTO_UPDATE_TAP # Restore user path as it'll be refiltered by HOMEBREW_BREW_FILE (bin/brew) export PATH=${HOMEBREW_PATH}