Allow bump commands to auto-update core tap clones

This commit is contained in:
Bo Anderson 2023-06-19 03:50:47 +01:00
parent 1c081f379d
commit 55419bfd8b
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
2 changed files with 56 additions and 9 deletions

View File

@ -290,11 +290,31 @@ auto-update() {
fi
fi
# Skip auto-update if the Homebrew/brew repository has been checked in the
repo_fetch_heads=("${HOMEBREW_REPOSITORY}/.git/FETCH_HEAD")
# We might have done an auto-update recently, but not a core/cask clone auto-update.
# So we check the core/cask clone FETCH_HEAD too.
if [[ -n "${HOMEBREW_UPDATE_CORE_TAP}" && -d "${HOMEBREW_CORE_REPOSITORY}/.git" ]]
then
repo_fetch_heads+=("${HOMEBREW_CORE_REPOSITORY}/.git/FETCH_HEAD")
fi
if [[ -n "${HOMEBREW_UPDATE_CASK_TAP}" && -d "${HOMEBREW_CASK_REPOSITORY}/.git" ]]
then
repo_fetch_heads+=("${HOMEBREW_CASK_REPOSITORY}/.git/FETCH_HEAD")
fi
# Skip auto-update if all of the selected repositories have been checked in the
# last $HOMEBREW_AUTO_UPDATE_SECS.
repo_fetch_head="${HOMEBREW_REPOSITORY}/.git/FETCH_HEAD"
if [[ -f "${repo_fetch_head}" ]] &&
[[ -n "$(find "${repo_fetch_head}" -type f -mtime -"${HOMEBREW_AUTO_UPDATE_SECS}"s 2>/dev/null)" ]]
needs_auto_update=
for repo_fetch_head in "${repo_fetch_heads[@]}"
do
if [[ ! -f "${repo_fetch_head}" ]] ||
[[ -z "$(find "${repo_fetch_head}" -type f -mtime -"${HOMEBREW_AUTO_UPDATE_SECS}"s 2>/dev/null)" ]]
then
needs_auto_update=1
break
fi
done
if [[ -z "${needs_auto_update}" ]]
then
return
fi
@ -323,6 +343,10 @@ auto-update() {
fi
unset AUTO_UPDATE_COMMANDS
unset AUTO_UPDATE_CORE_TAP_COMMANDS
unset AUTO_UPDATE_CASK_TAP_COMMANDS
unset HOMEBREW_UPDATE_CORE_TAP
unset HOMEBREW_UPDATE_CASK_TAP
}
#####
@ -807,13 +831,13 @@ then
unset HOMEBREW_RUBY_WARNINGS
fi
unset HOMEBREW_AUTO_UPDATE_COMMAND
# Check for commands that should call `brew update --auto-update` first.
AUTO_UPDATE_COMMANDS=(
install
outdated
upgrade
bump-formula-pr
bump-cask-pr
bundle
release
)
@ -823,6 +847,28 @@ then
export HOMEBREW_AUTO_UPDATE_COMMAND="1"
fi
# Check for commands that should auto-update the homebrew-core tap.
AUTO_UPDATE_CORE_TAP_COMMANDS=(
bump
bump-formula-pr
)
if check-array-membership "${HOMEBREW_COMMAND}" "${AUTO_UPDATE_CORE_TAP_COMMANDS[@]}"
then
export HOMEBREW_AUTO_UPDATE_COMMAND="1"
export HOMEBREW_UPDATE_CORE_TAP="1"
fi
# Check for commands that should auto-update the homebrew-cask tap.
AUTO_UPDATE_CASK_TAP_COMMANDS=(
bump
bump-cask-pr
)
if check-array-membership "${HOMEBREW_COMMAND}" "${AUTO_UPDATE_CASK_TAP_COMMANDS[@]}"
then
export HOMEBREW_AUTO_UPDATE_COMMAND="1"
export HOMEBREW_UPDATE_CASK_TAP="1"
fi
# Disable Ruby options we don't need.
export HOMEBREW_RUBY_DISABLE_OPTIONS="--disable=gems,rubyopt"

View File

@ -575,7 +575,8 @@ EOS
for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
do
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" && -n "${HOMEBREW_UPDATE_AUTO}" ]] &&
[[ "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" || "${DIR}" == "${HOMEBREW_CASK_REPOSITORY}" ]]
[[ ("${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" && -z "${HOMEBREW_UPDATE_CORE_TAP}") ||
("${DIR}" == "${HOMEBREW_CASK_REPOSITORY}" && -z "${HOMEBREW_UPDATE_CASK_TAP}") ]]
then
continue
fi
@ -731,8 +732,8 @@ EOS
do
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" ]] &&
[[ -z "${HOMEBREW_DEVELOPER}" || -n "${HOMEBREW_UPDATE_AUTO}" ]] &&
[[ "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" ||
"${DIR}" == "${HOMEBREW_CASK_REPOSITORY}" ]]
[[ ("${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" && -z "${HOMEBREW_UPDATE_CORE_TAP}") ||
("${DIR}" == "${HOMEBREW_CASK_REPOSITORY}" && -z "${HOMEBREW_UPDATE_CASK_TAP}") ]]
then
continue
fi