cmd/update-reset: accept tap names as arguments

Currently, doing `brew update-reset homebrew/core` does nothing (not
even return an error). If you want to `update-reset` a given tap, you
must do (the equivalent of)

    brew update-reset "$(brew --repository owner/tap_name)"

This isn't very intuitive, so let's do a bit more work in argument
parsing so that the user can just pass a tap name instead of a path to a
tap.

Passing a path to a tap is also still supported.
This commit is contained in:
Carlo Cabrera 2023-02-16 23:57:31 +08:00
parent 17c872fb52
commit ac7dbc0082
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -33,7 +33,22 @@ homebrew-update-reset() {
[[ "${option}" == *d* ]] && HOMEBREW_DEBUG=1
;;
*)
REPOS+=("${option}")
if [[ -d "${option}" ]]
then
REPOS+=("${option}")
else
local owner="${option%/*}"
local name="${option#*/}"
name="${name#homebrew-}" # Support both homebrew/core and homebrew/homebrew-core.
local repo_path="${HOMEBREW_LIBRARY}/Taps/${owner}/homebrew-${name}"
if [[ -d "${repo_path}" ]]
then
REPOS+=("${repo_path}")
else
odie "Could not find tap: ${option}"
fi
fi
;;
esac
done