update/update-reset: warn when no origin remote

Current situation with update.sh & update-reset.sh:

Upon creating a new tap and before adding remote 'origin' to it,
running `brew update` produces multiple cryptic error messages.
This change converts these cryptic Git messages into clear warnings
about absent remote 'origin'.

How to test:
1. Create a new tap using `brew tap-new`
2. Run `brew update`
This commit is contained in:
Maxim Belkin 2022-04-25 04:22:12 -07:00
parent 0495735eec
commit 27a2dba340
No known key found for this signature in database
GPG Key ID: AC71560D4C5F2338
2 changed files with 16 additions and 0 deletions

View File

@ -17,6 +17,7 @@ git() {
} }
homebrew-update-reset() { homebrew-update-reset() {
local option
local DIR local DIR
local -a REPOS=() local -a REPOS=()
@ -50,6 +51,11 @@ homebrew-update-reset() {
for DIR in "${REPOS[@]}" for DIR in "${REPOS[@]}"
do do
[[ -d "${DIR}/.git" ]] || continue [[ -d "${DIR}/.git" ]] || continue
if ! git -C "${DIR}" config --local --get remote.origin.url &>/dev/null
then
opoo "No remote 'origin' in: ${DIR}"
continue
fi
ohai "Fetching ${DIR}..." ohai "Fetching ${DIR}..."
git -C "${DIR}" fetch --force --tags origin git -C "${DIR}" fetch --force --tags origin
git -C "${DIR}" remote set-head origin --auto >/dev/null git -C "${DIR}" remote set-head origin --auto >/dev/null

View File

@ -555,6 +555,11 @@ EOS
[[ -d "${DIR}/.git" ]] || continue [[ -d "${DIR}/.git" ]] || continue
cd "${DIR}" || continue cd "${DIR}" || continue
if ! git config --local --get remote.origin.url &>/dev/null
then
opoo "No remote 'origin' in: ${DIR}"
continue
fi
if [[ -n "${HOMEBREW_VERBOSE}" ]] if [[ -n "${HOMEBREW_VERBOSE}" ]]
then then
echo "Checking if we need to fetch ${DIR}..." echo "Checking if we need to fetch ${DIR}..."
@ -706,6 +711,11 @@ EOS
[[ -d "${DIR}/.git" ]] || continue [[ -d "${DIR}/.git" ]] || continue
cd "${DIR}" || continue cd "${DIR}" || continue
if ! git config --local --get remote.origin.url &>/dev/null
then
# No need to display a (duplicate) warning here
continue
fi
TAP_VAR="$(repo_var "${DIR}")" TAP_VAR="$(repo_var "${DIR}")"
UPSTREAM_BRANCH_VAR="UPSTREAM_BRANCH${TAP_VAR}" UPSTREAM_BRANCH_VAR="UPSTREAM_BRANCH${TAP_VAR}"