Merge pull request #11241 from GauthamGoli/update-reset-style-fixes

update-reset.sh: Fix `shellcheck` style errors
This commit is contained in:
Mike McQuaid 2021-04-26 15:44:29 +01:00 committed by GitHub
commit 4af9a35f10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,40 +10,40 @@ homebrew-update-reset() {
for option in "$@" for option in "$@"
do do
case "$option" in case "${option}" in
-\?|-h|--help|--usage) brew help update-reset; exit $? ;; -\?|-h|--help|--usage) brew help update-reset; exit $? ;;
--debug) HOMEBREW_DEBUG=1 ;; --debug) HOMEBREW_DEBUG=1 ;;
-*) -*)
[[ "$option" = *d* ]] && HOMEBREW_DEBUG=1 [[ "${option}" = *d* ]] && HOMEBREW_DEBUG=1
;; ;;
*) *)
REPOS+=("$option") REPOS+=("${option}")
;; ;;
esac esac
done done
if [[ -n "$HOMEBREW_DEBUG" ]] if [[ -n "${HOMEBREW_DEBUG}" ]]
then then
set -x set -x
fi fi
if [[ -z "${REPOS[*]}" ]] if [[ -z "${REPOS[*]}" ]]
then then
REPOS+=("$HOMEBREW_REPOSITORY" "$HOMEBREW_LIBRARY"/Taps/*/*) REPOS+=("${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*)
fi fi
for DIR in "${REPOS[@]}" for DIR in "${REPOS[@]}"
do do
[[ -d "$DIR/.git" ]] || continue [[ -d "${DIR}/.git" ]] || continue
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
echo echo
ohai "Resetting $DIR..." ohai "Resetting ${DIR}..."
head="$(git -C "$DIR" symbolic-ref refs/remotes/origin/HEAD)" head="$(git -C "${DIR}" symbolic-ref refs/remotes/origin/HEAD)"
head="${head#refs/remotes/origin/}" head="${head#refs/remotes/origin/}"
git -C "$DIR" checkout --force -B "$head" origin/HEAD git -C "${DIR}" checkout --force -B "${head}" origin/HEAD
echo echo
done done
} }