cmd/update.sh: repair bash style
This commit is contained in:
parent
afa99b4963
commit
740cf7b6a1
@ -9,31 +9,38 @@
|
|||||||
#: -d, --debug Display a trace of all shell commands as they are executed.
|
#: -d, --debug Display a trace of all shell commands as they are executed.
|
||||||
#: -h, --help Show this message.
|
#: -h, --help Show this message.
|
||||||
|
|
||||||
source "$HOMEBREW_LIBRARY/Homebrew/utils/lock.sh"
|
# HOMEBREW_CURLRC, HOMEBREW_DEVELOPER, HOMEBREW_GIT_EMAIL, HOMEBREW_GIT_NAME
|
||||||
|
# HOMEBREW_UPDATE_CLEANUP, HOMEBREW_UPDATE_TO_TAG are from the user environment
|
||||||
|
# HOMEBREW_LIBRARY, HOMEBREW_PREFIX, HOMEBREW_REPOSITORY are set by bin/brew
|
||||||
|
# HOMEBREW_BREW_DEFAULT_GIT_REMOTE, HOMEBREW_BREW_GIT_REMOTE, HOMEBREW_CACHE, HOMEBREW_CELLAR, HOMEBREW_CURL
|
||||||
|
# HOMEBREW_DEV_CMD_RUN, HOMEBREW_FORCE_BREWED_CURL, HOMEBREW_FORCE_BREWED_GIT, HOMEBREW_SYSTEM_CURL_TOO_OLD
|
||||||
|
# HOMEBREW_USER_AGENT_CURL are set by brew.sh
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
source "${HOMEBREW_LIBRARY}/Homebrew/utils/lock.sh"
|
||||||
|
|
||||||
# Replaces the function in Library/Homebrew/brew.sh to cache the Git executable to
|
# Replaces the function in Library/Homebrew/brew.sh to cache the Git executable to
|
||||||
# provide speedup when using Git repeatedly (as update.sh does).
|
# provide speedup when using Git repeatedly (as update.sh does).
|
||||||
git() {
|
git() {
|
||||||
if [[ -z "$GIT_EXECUTABLE" ]]
|
if [[ -z "${GIT_EXECUTABLE}" ]]
|
||||||
then
|
then
|
||||||
GIT_EXECUTABLE="$("$HOMEBREW_LIBRARY/Homebrew/shims/scm/git" --homebrew=print-path)"
|
GIT_EXECUTABLE="$("${HOMEBREW_LIBRARY}/Homebrew/shims/scm/git" --homebrew=print-path)"
|
||||||
fi
|
fi
|
||||||
"$GIT_EXECUTABLE" "$@"
|
"${GIT_EXECUTABLE}" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
git_init_if_necessary() {
|
git_init_if_necessary() {
|
||||||
safe_cd "$HOMEBREW_REPOSITORY"
|
safe_cd "${HOMEBREW_REPOSITORY}"
|
||||||
if [[ ! -d ".git" ]]
|
if [[ ! -d ".git" ]]
|
||||||
then
|
then
|
||||||
set -e
|
set -e
|
||||||
trap '{ rm -rf .git; exit 1; }' EXIT
|
trap '{ rm -rf .git; exit 1; }' EXIT
|
||||||
git init
|
git init
|
||||||
git config --bool core.autocrlf false
|
git config --bool core.autocrlf false
|
||||||
if [[ "$HOMEBREW_BREW_DEFAULT_GIT_REMOTE" != "$HOMEBREW_BREW_GIT_REMOTE" ]]
|
if [[ "${HOMEBREW_BREW_DEFAULT_GIT_REMOTE}" != "${HOMEBREW_BREW_GIT_REMOTE}" ]]
|
||||||
then
|
then
|
||||||
echo "HOMEBREW_BREW_GIT_REMOTE set: using $HOMEBREW_BREW_GIT_REMOTE for Homebrew/brew Git remote URL."
|
echo "HOMEBREW_BREW_GIT_REMOTE set: using ${HOMEBREW_BREW_GIT_REMOTE} for Homebrew/brew Git remote URL."
|
||||||
fi
|
fi
|
||||||
git config remote.origin.url "$HOMEBREW_BREW_GIT_REMOTE"
|
git config remote.origin.url "${HOMEBREW_BREW_GIT_REMOTE}"
|
||||||
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
||||||
git fetch --force --tags origin
|
git fetch --force --tags origin
|
||||||
git remote set-head origin --auto >/dev/null
|
git remote set-head origin --auto >/dev/null
|
||||||
@ -43,19 +50,19 @@ git_init_if_necessary() {
|
|||||||
trap - EXIT
|
trap - EXIT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] || return
|
[[ -d "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]] || return
|
||||||
safe_cd "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core"
|
safe_cd "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core"
|
||||||
if [[ ! -d ".git" ]]
|
if [[ ! -d ".git" ]]
|
||||||
then
|
then
|
||||||
set -e
|
set -e
|
||||||
trap '{ rm -rf .git; exit 1; }' EXIT
|
trap '{ rm -rf .git; exit 1; }' EXIT
|
||||||
git init
|
git init
|
||||||
git config --bool core.autocrlf false
|
git config --bool core.autocrlf false
|
||||||
if [[ "$HOMEBREW_CORE_DEFAULT_GIT_REMOTE" != "$HOMEBREW_CORE_GIT_REMOTE" ]]
|
if [[ "${HOMEBREW_CORE_DEFAULT_GIT_REMOTE}" != "${HOMEBREW_CORE_GIT_REMOTE}" ]]
|
||||||
then
|
then
|
||||||
echo "HOMEBREW_CORE_GIT_REMOTE set: using $HOMEBREW_CORE_GIT_REMOTE for Homebrew/core Git remote URL."
|
echo "HOMEBREW_CORE_GIT_REMOTE set: using ${HOMEBREW_CORE_GIT_REMOTE} for Homebrew/core Git remote URL."
|
||||||
fi
|
fi
|
||||||
git config remote.origin.url "$HOMEBREW_CORE_GIT_REMOTE"
|
git config remote.origin.url "${HOMEBREW_CORE_GIT_REMOTE}"
|
||||||
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
||||||
git fetch --force origin refs/heads/master:refs/remotes/origin/master
|
git fetch --force origin refs/heads/master:refs/remotes/origin/master
|
||||||
git remote set-head origin --auto >/dev/null
|
git remote set-head origin --auto >/dev/null
|
||||||
@ -70,28 +77,28 @@ repo_var() {
|
|||||||
local repo_var
|
local repo_var
|
||||||
|
|
||||||
repo_var="$1"
|
repo_var="$1"
|
||||||
if [[ "$repo_var" = "$HOMEBREW_REPOSITORY" ]]
|
if [[ "${repo_var}" = "${HOMEBREW_REPOSITORY}" ]]
|
||||||
then
|
then
|
||||||
repo_var=""
|
repo_var=""
|
||||||
else
|
else
|
||||||
repo_var="${repo_var#"$HOMEBREW_LIBRARY/Taps"}"
|
repo_var="${repo_var#"${HOMEBREW_LIBRARY}/Taps"}"
|
||||||
repo_var="$(echo -n "$repo_var" | tr -C "A-Za-z0-9" "_" | tr "[:lower:]" "[:upper:]")"
|
repo_var="$(echo -n "${repo_var}" | tr -C "A-Za-z0-9" "_" | tr "[:lower:]" "[:upper:]")"
|
||||||
fi
|
fi
|
||||||
echo "$repo_var"
|
echo "${repo_var}"
|
||||||
}
|
}
|
||||||
|
|
||||||
upstream_branch() {
|
upstream_branch() {
|
||||||
local upstream_branch
|
local upstream_branch
|
||||||
|
|
||||||
upstream_branch="$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null)"
|
upstream_branch="$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null)"
|
||||||
if [[ -z "$upstream_branch" ]]
|
if [[ -z "${upstream_branch}" ]]
|
||||||
then
|
then
|
||||||
git remote set-head origin --auto >/dev/null
|
git remote set-head origin --auto >/dev/null
|
||||||
upstream_branch="$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null)"
|
upstream_branch="$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null)"
|
||||||
fi
|
fi
|
||||||
upstream_branch="${upstream_branch#refs/remotes/origin/}"
|
upstream_branch="${upstream_branch#refs/remotes/origin/}"
|
||||||
[[ -z "$upstream_branch" ]] && upstream_branch="master"
|
[[ -z "${upstream_branch}" ]] && upstream_branch="master"
|
||||||
echo "$upstream_branch"
|
echo "${upstream_branch}"
|
||||||
}
|
}
|
||||||
|
|
||||||
read_current_revision() {
|
read_current_revision() {
|
||||||
@ -99,10 +106,10 @@ read_current_revision() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pop_stash() {
|
pop_stash() {
|
||||||
[[ -z "$STASHED" ]] && return
|
[[ -z "${STASHED}" ]] && return
|
||||||
if [[ -n "$HOMEBREW_VERBOSE" ]]
|
if [[ -n "${HOMEBREW_VERBOSE}" ]]
|
||||||
then
|
then
|
||||||
echo "Restoring your stashed changes to $DIR..."
|
echo "Restoring your stashed changes to ${DIR}..."
|
||||||
git stash pop
|
git stash pop
|
||||||
else
|
else
|
||||||
git stash pop "${QUIET_ARGS[@]}" 1>/dev/null
|
git stash pop "${QUIET_ARGS[@]}" 1>/dev/null
|
||||||
@ -111,26 +118,26 @@ pop_stash() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pop_stash_message() {
|
pop_stash_message() {
|
||||||
[[ -z "$STASHED" ]] && return
|
[[ -z "${STASHED}" ]] && return
|
||||||
echo "To restore the stashed changes to $DIR, run:"
|
echo "To restore the stashed changes to ${DIR}, run:"
|
||||||
echo " cd $DIR && git stash pop"
|
echo " cd ${DIR} && git stash pop"
|
||||||
unset STASHED
|
unset STASHED
|
||||||
}
|
}
|
||||||
|
|
||||||
reset_on_interrupt() {
|
reset_on_interrupt() {
|
||||||
if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]]
|
if [[ "${INITIAL_BRANCH}" != "${UPSTREAM_BRANCH}" && -n "${INITIAL_BRANCH}" ]]
|
||||||
then
|
then
|
||||||
git checkout "$INITIAL_BRANCH" "${QUIET_ARGS[@]}"
|
git checkout "${INITIAL_BRANCH}" "${QUIET_ARGS[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$INITIAL_REVISION" ]]
|
if [[ -n "${INITIAL_REVISION}" ]]
|
||||||
then
|
then
|
||||||
git rebase --abort &>/dev/null
|
git rebase --abort &>/dev/null
|
||||||
git merge --abort &>/dev/null
|
git merge --abort &>/dev/null
|
||||||
git reset --hard "$INITIAL_REVISION" "${QUIET_ARGS[@]}"
|
git reset --hard "${INITIAL_REVISION}" "${QUIET_ARGS[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$HOMEBREW_NO_UPDATE_CLEANUP" ]]
|
if [[ -n "${HOMEBREW_NO_UPDATE_CLEANUP}" ]]
|
||||||
then
|
then
|
||||||
pop_stash
|
pop_stash
|
||||||
else
|
else
|
||||||
@ -150,28 +157,28 @@ simulate_from_current_branch() {
|
|||||||
local CURRENT_REVISION
|
local CURRENT_REVISION
|
||||||
|
|
||||||
DIR="$1"
|
DIR="$1"
|
||||||
cd "$DIR" || return
|
cd "${DIR}" || return
|
||||||
TAP_VAR="$2"
|
TAP_VAR="$2"
|
||||||
UPSTREAM_BRANCH="$3"
|
UPSTREAM_BRANCH="$3"
|
||||||
CURRENT_REVISION="$4"
|
CURRENT_REVISION="$4"
|
||||||
|
|
||||||
INITIAL_REVISION="$(git rev-parse -q --verify "$UPSTREAM_BRANCH")"
|
INITIAL_REVISION="$(git rev-parse -q --verify "${UPSTREAM_BRANCH}")"
|
||||||
export HOMEBREW_UPDATE_BEFORE"$TAP_VAR"="$INITIAL_REVISION"
|
export HOMEBREW_UPDATE_BEFORE"${TAP_VAR}"="${INITIAL_REVISION}"
|
||||||
export HOMEBREW_UPDATE_AFTER"$TAP_VAR"="$CURRENT_REVISION"
|
export HOMEBREW_UPDATE_AFTER"${TAP_VAR}"="${CURRENT_REVISION}"
|
||||||
if [[ "$INITIAL_REVISION" != "$CURRENT_REVISION" ]]
|
if [[ "${INITIAL_REVISION}" != "${CURRENT_REVISION}" ]]
|
||||||
then
|
then
|
||||||
HOMEBREW_UPDATED="1"
|
HOMEBREW_UPDATED="1"
|
||||||
fi
|
fi
|
||||||
if ! git merge-base --is-ancestor "$INITIAL_REVISION" "$CURRENT_REVISION"
|
if ! git merge-base --is-ancestor "${INITIAL_REVISION}" "${CURRENT_REVISION}"
|
||||||
then
|
then
|
||||||
odie "Your $DIR HEAD is not a descendant of $UPSTREAM_BRANCH!"
|
odie "Your ${DIR} HEAD is not a descendant of ${UPSTREAM_BRANCH}!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
merge_or_rebase() {
|
merge_or_rebase() {
|
||||||
if [[ -n "$HOMEBREW_VERBOSE" ]]
|
if [[ -n "${HOMEBREW_VERBOSE}" ]]
|
||||||
then
|
then
|
||||||
echo "Updating $DIR..."
|
echo "Updating ${DIR}..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local DIR
|
local DIR
|
||||||
@ -179,14 +186,14 @@ merge_or_rebase() {
|
|||||||
local UPSTREAM_BRANCH
|
local UPSTREAM_BRANCH
|
||||||
|
|
||||||
DIR="$1"
|
DIR="$1"
|
||||||
cd "$DIR" || return
|
cd "${DIR}" || return
|
||||||
TAP_VAR="$2"
|
TAP_VAR="$2"
|
||||||
UPSTREAM_BRANCH="$3"
|
UPSTREAM_BRANCH="$3"
|
||||||
unset STASHED
|
unset STASHED
|
||||||
|
|
||||||
trap reset_on_interrupt SIGINT
|
trap reset_on_interrupt SIGINT
|
||||||
|
|
||||||
if [[ "$DIR" = "$HOMEBREW_REPOSITORY" && -n "$HOMEBREW_UPDATE_TO_TAG" ]]
|
if [[ "${DIR}" = "${HOMEBREW_REPOSITORY}" && -n "${HOMEBREW_UPDATE_TO_TAG}" ]]
|
||||||
then
|
then
|
||||||
UPSTREAM_TAG="$(git tag --list |
|
UPSTREAM_TAG="$(git tag --list |
|
||||||
sort --field-separator=. --key=1,1nr -k 2,2nr -k 3,3nr |
|
sort --field-separator=. --key=1,1nr -k 2,2nr -k 3,3nr |
|
||||||
@ -195,19 +202,19 @@ merge_or_rebase() {
|
|||||||
UPSTREAM_TAG=""
|
UPSTREAM_TAG=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$UPSTREAM_TAG" ]
|
if [ -n "${UPSTREAM_TAG}" ]
|
||||||
then
|
then
|
||||||
REMOTE_REF="refs/tags/$UPSTREAM_TAG"
|
REMOTE_REF="refs/tags/${UPSTREAM_TAG}"
|
||||||
UPSTREAM_BRANCH="stable"
|
UPSTREAM_BRANCH="stable"
|
||||||
else
|
else
|
||||||
REMOTE_REF="origin/$UPSTREAM_BRANCH"
|
REMOTE_REF="origin/${UPSTREAM_BRANCH}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$(git status --untracked-files=all --porcelain 2>/dev/null)" ]]
|
if [[ -n "$(git status --untracked-files=all --porcelain 2>/dev/null)" ]]
|
||||||
then
|
then
|
||||||
if [[ -n "$HOMEBREW_VERBOSE" ]]
|
if [[ -n "${HOMEBREW_VERBOSE}" ]]
|
||||||
then
|
then
|
||||||
echo "Stashing uncommitted changes to $DIR..."
|
echo "Stashing uncommitted changes to ${DIR}..."
|
||||||
fi
|
fi
|
||||||
git merge --abort &>/dev/null
|
git merge --abort &>/dev/null
|
||||||
git rebase --abort &>/dev/null
|
git rebase --abort &>/dev/null
|
||||||
@ -217,9 +224,9 @@ merge_or_rebase() {
|
|||||||
stash save --include-untracked "${QUIET_ARGS[@]}"
|
stash save --include-untracked "${QUIET_ARGS[@]}"
|
||||||
then
|
then
|
||||||
odie <<EOS
|
odie <<EOS
|
||||||
Could not 'git stash' in $DIR!
|
Could not 'git stash' in ${DIR}!
|
||||||
Please stash/commit manually if you need to keep your changes or, if not, run:
|
Please stash/commit manually if you need to keep your changes or, if not, run:
|
||||||
cd $DIR
|
cd ${DIR}
|
||||||
git reset --hard origin/master
|
git reset --hard origin/master
|
||||||
EOS
|
EOS
|
||||||
fi
|
fi
|
||||||
@ -228,63 +235,63 @@ EOS
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
INITIAL_BRANCH="$(git symbolic-ref --short HEAD 2>/dev/null)"
|
INITIAL_BRANCH="$(git symbolic-ref --short HEAD 2>/dev/null)"
|
||||||
if [[ -n "$UPSTREAM_TAG" ]] ||
|
if [[ -n "${UPSTREAM_TAG}" ]] ||
|
||||||
[[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]]
|
[[ "${INITIAL_BRANCH}" != "${UPSTREAM_BRANCH}" && -n "${INITIAL_BRANCH}" ]]
|
||||||
then
|
then
|
||||||
# Recreate and check out `#{upstream_branch}` if unable to fast-forward
|
# Recreate and check out `#{upstream_branch}` if unable to fast-forward
|
||||||
# it to `origin/#{@upstream_branch}`. Otherwise, just check it out.
|
# it to `origin/#{@upstream_branch}`. Otherwise, just check it out.
|
||||||
if [[ -z "$UPSTREAM_TAG" ]] &&
|
if [[ -z "${UPSTREAM_TAG}" ]] &&
|
||||||
git merge-base --is-ancestor "$UPSTREAM_BRANCH" "$REMOTE_REF" &>/dev/null
|
git merge-base --is-ancestor "${UPSTREAM_BRANCH}" "${REMOTE_REF}" &>/dev/null
|
||||||
then
|
then
|
||||||
git checkout --force "$UPSTREAM_BRANCH" "${QUIET_ARGS[@]}"
|
git checkout --force "${UPSTREAM_BRANCH}" "${QUIET_ARGS[@]}"
|
||||||
else
|
else
|
||||||
if [[ -n "$UPSTREAM_TAG" && "$UPSTREAM_BRANCH" != "master" ]]
|
if [[ -n "${UPSTREAM_TAG}" && "${UPSTREAM_BRANCH}" != "master" ]]
|
||||||
then
|
then
|
||||||
git checkout --force -B "master" "origin/master" "${QUIET_ARGS[@]}"
|
git checkout --force -B "master" "origin/master" "${QUIET_ARGS[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git checkout --force -B "$UPSTREAM_BRANCH" "$REMOTE_REF" "${QUIET_ARGS[@]}"
|
git checkout --force -B "${UPSTREAM_BRANCH}" "${REMOTE_REF}" "${QUIET_ARGS[@]}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
INITIAL_REVISION="$(read_current_revision)"
|
INITIAL_REVISION="$(read_current_revision)"
|
||||||
export HOMEBREW_UPDATE_BEFORE"$TAP_VAR"="$INITIAL_REVISION"
|
export HOMEBREW_UPDATE_BEFORE"${TAP_VAR}"="${INITIAL_REVISION}"
|
||||||
|
|
||||||
# ensure we don't munge line endings on checkout
|
# ensure we don't munge line endings on checkout
|
||||||
git config core.autocrlf false
|
git config core.autocrlf false
|
||||||
|
|
||||||
if [[ -z "$HOMEBREW_MERGE" ]]
|
if [[ -z "${HOMEBREW_MERGE}" ]]
|
||||||
then
|
then
|
||||||
# Work around bug where git rebase --quiet is not quiet
|
# Work around bug where git rebase --quiet is not quiet
|
||||||
if [[ -z "$HOMEBREW_VERBOSE" ]]
|
if [[ -z "${HOMEBREW_VERBOSE}" ]]
|
||||||
then
|
then
|
||||||
git rebase "${QUIET_ARGS[@]}" "$REMOTE_REF" >/dev/null
|
git rebase "${QUIET_ARGS[@]}" "${REMOTE_REF}" >/dev/null
|
||||||
else
|
else
|
||||||
git rebase "${QUIET_ARGS[@]}" "$REMOTE_REF"
|
git rebase "${QUIET_ARGS[@]}" "${REMOTE_REF}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
git merge --no-edit --ff "${QUIET_ARGS[@]}" "$REMOTE_REF" \
|
git merge --no-edit --ff "${QUIET_ARGS[@]}" "${REMOTE_REF}" \
|
||||||
--strategy=recursive \
|
--strategy=recursive \
|
||||||
--strategy-option=ours \
|
--strategy-option=ours \
|
||||||
--strategy-option=ignore-all-space
|
--strategy-option=ignore-all-space
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CURRENT_REVISION="$(read_current_revision)"
|
CURRENT_REVISION="$(read_current_revision)"
|
||||||
export HOMEBREW_UPDATE_AFTER"$TAP_VAR"="$CURRENT_REVISION"
|
export HOMEBREW_UPDATE_AFTER"${TAP_VAR}"="${CURRENT_REVISION}"
|
||||||
|
|
||||||
if [[ "$INITIAL_REVISION" != "$CURRENT_REVISION" ]]
|
if [[ "${INITIAL_REVISION}" != "${CURRENT_REVISION}" ]]
|
||||||
then
|
then
|
||||||
HOMEBREW_UPDATED="1"
|
HOMEBREW_UPDATED="1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
trap '' SIGINT
|
trap '' SIGINT
|
||||||
|
|
||||||
if [[ -n "$HOMEBREW_NO_UPDATE_CLEANUP" ]]
|
if [[ -n "${HOMEBREW_NO_UPDATE_CLEANUP}" ]]
|
||||||
then
|
then
|
||||||
if [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" &&
|
if [[ "${INITIAL_BRANCH}" != "${UPSTREAM_BRANCH}" && -n "${INITIAL_BRANCH}" &&
|
||||||
! "$INITIAL_BRANCH" =~ ^v[0-9]+\.[0-9]+\.[0-9]|stable$ ]]
|
! "${INITIAL_BRANCH}" =~ ^v[0-9]+\.[0-9]+\.[0-9]|stable$ ]]
|
||||||
then
|
then
|
||||||
git checkout "$INITIAL_BRANCH" "${QUIET_ARGS[@]}"
|
git checkout "${INITIAL_BRANCH}" "${QUIET_ARGS[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pop_stash
|
pop_stash
|
||||||
@ -302,7 +309,7 @@ homebrew-update() {
|
|||||||
|
|
||||||
for option in "$@"
|
for option in "$@"
|
||||||
do
|
do
|
||||||
case "$option" in
|
case "${option}" in
|
||||||
-\?|-h|--help|--usage) brew help update; exit $? ;;
|
-\?|-h|--help|--usage) brew help update; exit $? ;;
|
||||||
--verbose) HOMEBREW_VERBOSE=1 ;;
|
--verbose) HOMEBREW_VERBOSE=1 ;;
|
||||||
--debug) HOMEBREW_DEBUG=1 ;;
|
--debug) HOMEBREW_DEBUG=1 ;;
|
||||||
@ -313,10 +320,10 @@ homebrew-update() {
|
|||||||
--preinstall) export HOMEBREW_UPDATE_PREINSTALL=1 ;;
|
--preinstall) export HOMEBREW_UPDATE_PREINSTALL=1 ;;
|
||||||
--*) ;;
|
--*) ;;
|
||||||
-*)
|
-*)
|
||||||
[[ "$option" = *v* ]] && HOMEBREW_VERBOSE=1
|
[[ "${option}" = *v* ]] && HOMEBREW_VERBOSE=1
|
||||||
[[ "$option" = *q* ]] && HOMEBREW_QUIET=1
|
[[ "${option}" = *q* ]] && HOMEBREW_QUIET=1
|
||||||
[[ "$option" = *d* ]] && HOMEBREW_DEBUG=1
|
[[ "${option}" = *d* ]] && HOMEBREW_DEBUG=1
|
||||||
[[ "$option" = *f* ]] && HOMEBREW_UPDATE_FORCE=1
|
[[ "${option}" = *f* ]] && HOMEBREW_UPDATE_FORCE=1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
odie <<EOS
|
odie <<EOS
|
||||||
@ -327,14 +334,14 @@ EOS
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -n "$HOMEBREW_DEBUG" ]]
|
if [[ -n "${HOMEBREW_DEBUG}" ]]
|
||||||
then
|
then
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$HOMEBREW_UPDATE_CLEANUP" && -z "$HOMEBREW_UPDATE_TO_TAG" ]]
|
if [[ -z "${HOMEBREW_UPDATE_CLEANUP}" && -z "${HOMEBREW_UPDATE_TO_TAG}" ]]
|
||||||
then
|
then
|
||||||
if [[ -n "$HOMEBREW_DEVELOPER" || -n "$HOMEBREW_DEV_CMD_RUN" ]]
|
if [[ -n "${HOMEBREW_DEVELOPER}" || -n "${HOMEBREW_DEV_CMD_RUN}" ]]
|
||||||
then
|
then
|
||||||
export HOMEBREW_NO_UPDATE_CLEANUP="1"
|
export HOMEBREW_NO_UPDATE_CLEANUP="1"
|
||||||
else
|
else
|
||||||
@ -343,51 +350,51 @@ EOS
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# check permissions
|
# check permissions
|
||||||
if [[ -e "$HOMEBREW_CELLAR" && ! -w "$HOMEBREW_CELLAR" ]]
|
if [[ -e "${HOMEBREW_CELLAR}" && ! -w "${HOMEBREW_CELLAR}" ]]
|
||||||
then
|
then
|
||||||
odie <<EOS
|
odie <<EOS
|
||||||
$HOMEBREW_CELLAR is not writable. You should change the
|
${HOMEBREW_CELLAR} is not writable. You should change the
|
||||||
ownership and permissions of $HOMEBREW_CELLAR back to your
|
ownership and permissions of ${HOMEBREW_CELLAR} back to your
|
||||||
user account:
|
user account:
|
||||||
sudo chown -R \$(whoami) $HOMEBREW_CELLAR
|
sudo chown -R \$(whoami) ${HOMEBREW_CELLAR}
|
||||||
EOS
|
EOS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -w "$HOMEBREW_REPOSITORY" ]]
|
if [[ ! -w "${HOMEBREW_REPOSITORY}" ]]
|
||||||
then
|
then
|
||||||
odie <<EOS
|
odie <<EOS
|
||||||
$HOMEBREW_REPOSITORY is not writable. You should change the
|
${HOMEBREW_REPOSITORY} is not writable. You should change the
|
||||||
ownership and permissions of $HOMEBREW_REPOSITORY back to your
|
ownership and permissions of ${HOMEBREW_REPOSITORY} back to your
|
||||||
user account:
|
user account:
|
||||||
sudo chown -R \$(whoami) $HOMEBREW_REPOSITORY
|
sudo chown -R \$(whoami) ${HOMEBREW_REPOSITORY}
|
||||||
EOS
|
EOS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# we may want to use a Homebrew curl
|
# we may want to use a Homebrew curl
|
||||||
if [[ -n "$HOMEBREW_FORCE_BREWED_CURL" &&
|
if [[ -n "${HOMEBREW_FORCE_BREWED_CURL}" &&
|
||||||
! -x "$HOMEBREW_PREFIX/opt/curl/bin/curl" ]]
|
! -x "${HOMEBREW_PREFIX}/opt/curl/bin/curl" ]]
|
||||||
then
|
then
|
||||||
# we cannot install a Homebrew cURL if homebrew/core is unavailable.
|
# we cannot install a Homebrew cURL if homebrew/core is unavailable.
|
||||||
if [[ ! -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] || ! brew install curl
|
if [[ ! -d "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]] || ! brew install curl
|
||||||
then
|
then
|
||||||
odie "'curl' must be installed and in your PATH!"
|
odie "'curl' must be installed and in your PATH!"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! git --version &>/dev/null ||
|
if ! git --version &>/dev/null ||
|
||||||
[[ -n "$HOMEBREW_FORCE_BREWED_GIT" &&
|
[[ -n "${HOMEBREW_FORCE_BREWED_GIT}" &&
|
||||||
! -x "$HOMEBREW_PREFIX/opt/git/bin/git" ]]
|
! -x "${HOMEBREW_PREFIX}/opt/git/bin/git" ]]
|
||||||
then
|
then
|
||||||
# we cannot install a Homebrew Git if homebrew/core is unavailable.
|
# we cannot install a Homebrew Git if homebrew/core is unavailable.
|
||||||
if [[ ! -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] || ! brew install git
|
if [[ ! -d "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]] || ! brew install git
|
||||||
then
|
then
|
||||||
odie "'git' must be installed and in your PATH!"
|
odie "'git' must be installed and in your PATH!"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -f "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core/.git/shallow" ]] && HOMEBREW_CORE_SHALLOW=1
|
[[ -f "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/.git/shallow" ]] && HOMEBREW_CORE_SHALLOW=1
|
||||||
[[ -f "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-cask/.git/shallow" ]] && HOMEBREW_CASK_SHALLOW=1
|
[[ -f "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-cask/.git/shallow" ]] && HOMEBREW_CASK_SHALLOW=1
|
||||||
if [[ -n $HOMEBREW_CORE_SHALLOW && -n $HOMEBREW_CASK_SHALLOW ]]
|
if [[ -n ${HOMEBREW_CORE_SHALLOW} && -n ${HOMEBREW_CASK_SHALLOW} ]]
|
||||||
then
|
then
|
||||||
SHALLOW_COMMAND_PHRASE="These commands"
|
SHALLOW_COMMAND_PHRASE="These commands"
|
||||||
SHALLOW_REPO_PHRASE="repositories"
|
SHALLOW_REPO_PHRASE="repositories"
|
||||||
@ -396,15 +403,15 @@ EOS
|
|||||||
SHALLOW_REPO_PHRASE="repository"
|
SHALLOW_REPO_PHRASE="repository"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n $HOMEBREW_CORE_SHALLOW || -n $HOMEBREW_CASK_SHALLOW ]]
|
if [[ -n ${HOMEBREW_CORE_SHALLOW} || -n ${HOMEBREW_CASK_SHALLOW} ]]
|
||||||
then
|
then
|
||||||
odie <<EOS
|
odie <<EOS
|
||||||
${HOMEBREW_CORE_SHALLOW:+
|
${HOMEBREW_CORE_SHALLOW:+
|
||||||
homebrew-core is a shallow clone.}${HOMEBREW_CASK_SHALLOW:+
|
homebrew-core is a shallow clone.}${HOMEBREW_CASK_SHALLOW:+
|
||||||
homebrew-cask is a shallow clone.}
|
homebrew-cask is a shallow clone.}
|
||||||
To \`brew update\`, first run:${HOMEBREW_CORE_SHALLOW:+
|
To \`brew update\`, first run:${HOMEBREW_CORE_SHALLOW:+
|
||||||
git -C "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" fetch --unshallow}${HOMEBREW_CASK_SHALLOW:+
|
git -C "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" fetch --unshallow}${HOMEBREW_CASK_SHALLOW:+
|
||||||
git -C "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-cask" fetch --unshallow}
|
git -C "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-cask" fetch --unshallow}
|
||||||
${SHALLOW_COMMAND_PHRASE} may take a few minutes to run due to the large size of the ${SHALLOW_REPO_PHRASE}.
|
${SHALLOW_COMMAND_PHRASE} may take a few minutes to run due to the large size of the ${SHALLOW_REPO_PHRASE}.
|
||||||
This restriction has been made on GitHub's request because updating shallow
|
This restriction has been made on GitHub's request because updating shallow
|
||||||
clones is an extremely expensive operation due to the tree layout and traffic of
|
clones is an extremely expensive operation due to the tree layout and traffic of
|
||||||
@ -418,26 +425,26 @@ EOS
|
|||||||
export GIT_TERMINAL_PROMPT="0"
|
export GIT_TERMINAL_PROMPT="0"
|
||||||
export GIT_SSH_COMMAND="ssh -oBatchMode=yes"
|
export GIT_SSH_COMMAND="ssh -oBatchMode=yes"
|
||||||
|
|
||||||
if [[ -n "$HOMEBREW_GIT_NAME" ]]
|
if [[ -n "${HOMEBREW_GIT_NAME}" ]]
|
||||||
then
|
then
|
||||||
export GIT_AUTHOR_NAME="$HOMEBREW_GIT_NAME"
|
export GIT_AUTHOR_NAME="${HOMEBREW_GIT_NAME}"
|
||||||
export GIT_COMMITTER_NAME="$HOMEBREW_GIT_NAME"
|
export GIT_COMMITTER_NAME="${HOMEBREW_GIT_NAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$HOMEBREW_GIT_EMAIL" ]]
|
if [[ -n "${HOMEBREW_GIT_EMAIL}" ]]
|
||||||
then
|
then
|
||||||
export GIT_AUTHOR_EMAIL="$HOMEBREW_GIT_EMAIL"
|
export GIT_AUTHOR_EMAIL="${HOMEBREW_GIT_EMAIL}"
|
||||||
export GIT_COMMITTER_EMAIL="$HOMEBREW_GIT_EMAIL"
|
export GIT_COMMITTER_EMAIL="${HOMEBREW_GIT_EMAIL}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$HOMEBREW_VERBOSE" ]]
|
if [[ -z "${HOMEBREW_VERBOSE}" ]]
|
||||||
then
|
then
|
||||||
QUIET_ARGS=(-q)
|
QUIET_ARGS=(-q)
|
||||||
else
|
else
|
||||||
QUIET_ARGS=()
|
QUIET_ARGS=()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$HOMEBREW_CURLRC" ]]
|
if [[ -z "${HOMEBREW_CURLRC}" ]]
|
||||||
then
|
then
|
||||||
CURL_DISABLE_CURLRC_ARGS=(-q)
|
CURL_DISABLE_CURLRC_ARGS=(-q)
|
||||||
else
|
else
|
||||||
@ -449,69 +456,69 @@ EOS
|
|||||||
|
|
||||||
git_init_if_necessary
|
git_init_if_necessary
|
||||||
|
|
||||||
if [[ "$HOMEBREW_BREW_DEFAULT_GIT_REMOTE" != "$HOMEBREW_BREW_GIT_REMOTE" ]]
|
if [[ "${HOMEBREW_BREW_DEFAULT_GIT_REMOTE}" != "${HOMEBREW_BREW_GIT_REMOTE}" ]]
|
||||||
then
|
then
|
||||||
safe_cd "$HOMEBREW_REPOSITORY"
|
safe_cd "${HOMEBREW_REPOSITORY}"
|
||||||
echo "HOMEBREW_BREW_GIT_REMOTE set: using $HOMEBREW_BREW_GIT_REMOTE for Homebrew/brew Git remote."
|
echo "HOMEBREW_BREW_GIT_REMOTE set: using ${HOMEBREW_BREW_GIT_REMOTE} for Homebrew/brew Git remote."
|
||||||
git remote set-url origin "$HOMEBREW_BREW_GIT_REMOTE"
|
git remote set-url origin "${HOMEBREW_BREW_GIT_REMOTE}"
|
||||||
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
||||||
git fetch --force --tags origin
|
git fetch --force --tags origin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$HOMEBREW_CORE_DEFAULT_GIT_REMOTE" != "$HOMEBREW_CORE_GIT_REMOTE" ]] &&
|
if [[ "${HOMEBREW_CORE_DEFAULT_GIT_REMOTE}" != "${HOMEBREW_CORE_GIT_REMOTE}" ]] &&
|
||||||
[[ -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]]
|
[[ -d "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]]
|
||||||
then
|
then
|
||||||
safe_cd "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core"
|
safe_cd "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core"
|
||||||
echo "HOMEBREW_CORE_GIT_REMOTE set: using $HOMEBREW_CORE_GIT_REMOTE for Homebrew/brew Git remote."
|
echo "HOMEBREW_CORE_GIT_REMOTE set: using ${HOMEBREW_CORE_GIT_REMOTE} for Homebrew/brew Git remote."
|
||||||
git remote set-url origin "$HOMEBREW_CORE_GIT_REMOTE"
|
git remote set-url origin "${HOMEBREW_CORE_GIT_REMOTE}"
|
||||||
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
||||||
git fetch --force origin refs/heads/master:refs/remotes/origin/master
|
git fetch --force origin refs/heads/master:refs/remotes/origin/master
|
||||||
fi
|
fi
|
||||||
|
|
||||||
safe_cd "$HOMEBREW_REPOSITORY"
|
safe_cd "${HOMEBREW_REPOSITORY}"
|
||||||
|
|
||||||
# if an older system had a newer curl installed, change each repo's remote URL from GIT to HTTPS
|
# if an older system had a newer curl installed, change each repo's remote URL from GIT to HTTPS
|
||||||
if [[ -n "$HOMEBREW_SYSTEM_CURL_TOO_OLD" &&
|
if [[ -n "${HOMEBREW_SYSTEM_CURL_TOO_OLD}" &&
|
||||||
-x "$HOMEBREW_PREFIX/opt/curl/bin/curl" &&
|
-x "${HOMEBREW_PREFIX}/opt/curl/bin/curl" &&
|
||||||
"$(git config remote.origin.url)" =~ ^git:// ]]
|
"$(git config remote.origin.url)" =~ ^git:// ]]
|
||||||
then
|
then
|
||||||
git config remote.origin.url "$HOMEBREW_BREW_GIT_REMOTE"
|
git config remote.origin.url "${HOMEBREW_BREW_GIT_REMOTE}"
|
||||||
git config -f "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core/.git/config" remote.origin.url "$HOMEBREW_CORE_GIT_REMOTE"
|
git config -f "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/.git/config" remote.origin.url "${HOMEBREW_CORE_GIT_REMOTE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# kill all of subprocess on interrupt
|
# kill all of subprocess on interrupt
|
||||||
trap '{ /usr/bin/pkill -P $$; wait; exit 130; }' SIGINT
|
trap '{ /usr/bin/pkill -P $$; wait; exit 130; }' SIGINT
|
||||||
|
|
||||||
local update_failed_file="$HOMEBREW_REPOSITORY/.git/UPDATE_FAILED"
|
local update_failed_file="${HOMEBREW_REPOSITORY}/.git/UPDATE_FAILED"
|
||||||
local missing_remote_ref_dirs_file="$HOMEBREW_REPOSITORY/.git/FAILED_FETCH_DIRS"
|
local missing_remote_ref_dirs_file="${HOMEBREW_REPOSITORY}/.git/FAILED_FETCH_DIRS"
|
||||||
rm -f "$update_failed_file"
|
rm -f "${update_failed_file}"
|
||||||
rm -f "$missing_remote_ref_dirs_file"
|
rm -f "${missing_remote_ref_dirs_file}"
|
||||||
|
|
||||||
for DIR in "$HOMEBREW_REPOSITORY" "$HOMEBREW_LIBRARY"/Taps/*/*
|
for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
|
||||||
do
|
do
|
||||||
[[ -d "$DIR/.git" ]] || continue
|
[[ -d "${DIR}/.git" ]] || continue
|
||||||
cd "$DIR" || continue
|
cd "${DIR}" || continue
|
||||||
|
|
||||||
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}..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TAP_VAR="$(repo_var "$DIR")"
|
TAP_VAR="$(repo_var "${DIR}")"
|
||||||
UPSTREAM_BRANCH_DIR="$(upstream_branch)"
|
UPSTREAM_BRANCH_DIR="$(upstream_branch)"
|
||||||
declare UPSTREAM_BRANCH"$TAP_VAR"="$UPSTREAM_BRANCH_DIR"
|
declare UPSTREAM_BRANCH"${TAP_VAR}"="${UPSTREAM_BRANCH_DIR}"
|
||||||
declare PREFETCH_REVISION"$TAP_VAR"="$(git rev-parse -q --verify refs/remotes/origin/"$UPSTREAM_BRANCH_DIR")"
|
declare PREFETCH_REVISION"${TAP_VAR}"="$(git rev-parse -q --verify refs/remotes/origin/"${UPSTREAM_BRANCH_DIR}")"
|
||||||
|
|
||||||
# Force a full update if we don't have any tags.
|
# Force a full update if we don't have any tags.
|
||||||
if [[ "$DIR" = "$HOMEBREW_REPOSITORY" && -z "$(git tag --list)" ]]
|
if [[ "${DIR}" = "${HOMEBREW_REPOSITORY}" && -z "$(git tag --list)" ]]
|
||||||
then
|
then
|
||||||
HOMEBREW_UPDATE_FORCE=1
|
HOMEBREW_UPDATE_FORCE=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$HOMEBREW_UPDATE_FORCE" ]]
|
if [[ -z "${HOMEBREW_UPDATE_FORCE}" ]]
|
||||||
then
|
then
|
||||||
[[ -n "$SKIP_FETCH_BREW_REPOSITORY" && "$DIR" = "$HOMEBREW_REPOSITORY" ]] && continue
|
[[ -n "${SKIP_FETCH_BREW_REPOSITORY}" && "${DIR}" = "${HOMEBREW_REPOSITORY}" ]] && continue
|
||||||
[[ -n "$SKIP_FETCH_CORE_REPOSITORY" && "$DIR" = "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] && continue
|
[[ -n "${SKIP_FETCH_CORE_REPOSITORY}" && "${DIR}" = "${HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core" ]] && continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The upstream repository's default branch may not be master;
|
# The upstream repository's default branch may not be master;
|
||||||
@ -523,12 +530,12 @@ EOS
|
|||||||
|
|
||||||
# HOMEBREW_UPDATE_FORCE and HOMEBREW_UPDATE_PREINSTALL aren't modified here so ignore subshell warning.
|
# HOMEBREW_UPDATE_FORCE and HOMEBREW_UPDATE_PREINSTALL aren't modified here so ignore subshell warning.
|
||||||
# shellcheck disable=SC2030
|
# shellcheck disable=SC2030
|
||||||
if [[ "$UPSTREAM_REPOSITORY_URL" = "https://github.com/"* ]]
|
if [[ "${UPSTREAM_REPOSITORY_URL}" = "https://github.com/"* ]]
|
||||||
then
|
then
|
||||||
UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY_URL#https://github.com/}"
|
UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY_URL#https://github.com/}"
|
||||||
UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY%.git}"
|
UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY%.git}"
|
||||||
|
|
||||||
if [[ "$DIR" = "$HOMEBREW_REPOSITORY" && -n "$HOMEBREW_UPDATE_TO_TAG" ]]
|
if [[ "${DIR}" = "${HOMEBREW_REPOSITORY}" && -n "${HOMEBREW_UPDATE_TO_TAG}" ]]
|
||||||
then
|
then
|
||||||
# Only try to `git fetch` when the upstream tags have changed
|
# Only try to `git fetch` when the upstream tags have changed
|
||||||
# (so the API does not return 304: unmodified).
|
# (so the API does not return 304: unmodified).
|
||||||
@ -538,30 +545,30 @@ EOS
|
|||||||
else
|
else
|
||||||
# Only try to `git fetch` when the upstream branch is at a different SHA
|
# Only try to `git fetch` when the upstream branch is at a different SHA
|
||||||
# (so the API does not return 304: unmodified).
|
# (so the API does not return 304: unmodified).
|
||||||
GITHUB_API_ETAG="$(git rev-parse "refs/remotes/origin/$UPSTREAM_BRANCH_DIR")"
|
GITHUB_API_ETAG="$(git rev-parse "refs/remotes/origin/${UPSTREAM_BRANCH_DIR}")"
|
||||||
GITHUB_API_ACCEPT="application/vnd.github.v3.sha"
|
GITHUB_API_ACCEPT="application/vnd.github.v3.sha"
|
||||||
GITHUB_API_ENDPOINT="commits/$UPSTREAM_BRANCH_DIR"
|
GITHUB_API_ENDPOINT="commits/${UPSTREAM_BRANCH_DIR}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# HOMEBREW_CURL is set by brew.sh (and isn't mispelt here)
|
# HOMEBREW_CURL is set by brew.sh (and isn't mispelt here)
|
||||||
# shellcheck disable=SC2153
|
# shellcheck disable=SC2153
|
||||||
UPSTREAM_SHA_HTTP_CODE="$("$HOMEBREW_CURL" \
|
UPSTREAM_SHA_HTTP_CODE="$("${HOMEBREW_CURL}" \
|
||||||
"${CURL_DISABLE_CURLRC_ARGS[@]}" \
|
"${CURL_DISABLE_CURLRC_ARGS[@]}" \
|
||||||
--silent --max-time 3 \
|
--silent --max-time 3 \
|
||||||
--location --no-remote-time --output /dev/null --write-out "%{http_code}" \
|
--location --no-remote-time --output /dev/null --write-out "%{http_code}" \
|
||||||
--dump-header "$DIR/.git/GITHUB_HEADERS" \
|
--dump-header "${DIR}/.git/GITHUB_HEADERS" \
|
||||||
--user-agent "$HOMEBREW_USER_AGENT_CURL" \
|
--user-agent "${HOMEBREW_USER_AGENT_CURL}" \
|
||||||
--header "Accept: $GITHUB_API_ACCEPT" \
|
--header "Accept: ${GITHUB_API_ACCEPT}" \
|
||||||
--header "If-None-Match: \"$GITHUB_API_ETAG\"" \
|
--header "If-None-Match: \"${GITHUB_API_ETAG}\"" \
|
||||||
"https://api.github.com/repos/$UPSTREAM_REPOSITORY/$GITHUB_API_ENDPOINT")"
|
"https://api.github.com/repos/${UPSTREAM_REPOSITORY}/${GITHUB_API_ENDPOINT}")"
|
||||||
|
|
||||||
# Touch FETCH_HEAD to confirm we've checked for an update.
|
# Touch FETCH_HEAD to confirm we've checked for an update.
|
||||||
[[ -f "$DIR/.git/FETCH_HEAD" ]] && touch "$DIR/.git/FETCH_HEAD"
|
[[ -f "${DIR}/.git/FETCH_HEAD" ]] && touch "${DIR}/.git/FETCH_HEAD"
|
||||||
[[ -z "$HOMEBREW_UPDATE_FORCE" ]] && [[ "$UPSTREAM_SHA_HTTP_CODE" = "304" ]] && exit
|
[[ -z "${HOMEBREW_UPDATE_FORCE}" ]] && [[ "${UPSTREAM_SHA_HTTP_CODE}" = "304" ]] && exit
|
||||||
elif [[ -n "$HOMEBREW_UPDATE_PREINSTALL" ]]
|
elif [[ -n "${HOMEBREW_UPDATE_PREINSTALL}" ]]
|
||||||
then
|
then
|
||||||
FORCE_AUTO_UPDATE="$(git config homebrew.forceautoupdate 2>/dev/null || echo "false")"
|
FORCE_AUTO_UPDATE="$(git config homebrew.forceautoupdate 2>/dev/null || echo "false")"
|
||||||
if [[ "$FORCE_AUTO_UPDATE" != "true" ]]
|
if [[ "${FORCE_AUTO_UPDATE}" != "true" ]]
|
||||||
then
|
then
|
||||||
# Don't try to do a `git fetch` that may take longer than expected.
|
# Don't try to do a `git fetch` that may take longer than expected.
|
||||||
exit
|
exit
|
||||||
@ -571,110 +578,110 @@ EOS
|
|||||||
|
|
||||||
# HOMEBREW_VERBOSE isn't modified here so ignore subshell warning.
|
# HOMEBREW_VERBOSE isn't modified here so ignore subshell warning.
|
||||||
# shellcheck disable=SC2030
|
# shellcheck disable=SC2030
|
||||||
if [[ -n "$HOMEBREW_VERBOSE" ]]
|
if [[ -n "${HOMEBREW_VERBOSE}" ]]
|
||||||
then
|
then
|
||||||
echo "Fetching $DIR..."
|
echo "Fetching ${DIR}..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local tmp_failure_file="$HOMEBREW_REPOSITORY/.git/TMP_FETCH_FAILURES"
|
local tmp_failure_file="${HOMEBREW_REPOSITORY}/.git/TMP_FETCH_FAILURES"
|
||||||
rm -f "$tmp_failure_file"
|
rm -f "${tmp_failure_file}"
|
||||||
|
|
||||||
if [[ -n "$HOMEBREW_UPDATE_PREINSTALL" ]]
|
if [[ -n "${HOMEBREW_UPDATE_PREINSTALL}" ]]
|
||||||
then
|
then
|
||||||
git fetch --tags --force "${QUIET_ARGS[@]}" origin \
|
git fetch --tags --force "${QUIET_ARGS[@]}" origin \
|
||||||
"refs/heads/$UPSTREAM_BRANCH_DIR:refs/remotes/origin/$UPSTREAM_BRANCH_DIR" 2>/dev/null
|
"refs/heads/${UPSTREAM_BRANCH_DIR}:refs/remotes/origin/${UPSTREAM_BRANCH_DIR}" 2>/dev/null
|
||||||
else
|
else
|
||||||
# Capture stderr to tmp_failure_file
|
# Capture stderr to tmp_failure_file
|
||||||
if ! git fetch --tags --force "${QUIET_ARGS[@]}" origin \
|
if ! git fetch --tags --force "${QUIET_ARGS[@]}" origin \
|
||||||
"refs/heads/$UPSTREAM_BRANCH_DIR:refs/remotes/origin/$UPSTREAM_BRANCH_DIR" 2>>"$tmp_failure_file"
|
"refs/heads/${UPSTREAM_BRANCH_DIR}:refs/remotes/origin/${UPSTREAM_BRANCH_DIR}" 2>>"${tmp_failure_file}"
|
||||||
then
|
then
|
||||||
# Reprint fetch errors to stderr
|
# Reprint fetch errors to stderr
|
||||||
[[ -f "$tmp_failure_file" ]] && cat "$tmp_failure_file" 1>&2
|
[[ -f "${tmp_failure_file}" ]] && cat "${tmp_failure_file}" 1>&2
|
||||||
|
|
||||||
if [[ "$UPSTREAM_SHA_HTTP_CODE" = "404" ]]
|
if [[ "${UPSTREAM_SHA_HTTP_CODE}" = "404" ]]
|
||||||
then
|
then
|
||||||
TAP="${DIR#$HOMEBREW_LIBRARY/Taps/}"
|
TAP="${DIR#${HOMEBREW_LIBRARY}/Taps/}"
|
||||||
echo "$TAP does not exist! Run \`brew untap $TAP\` to remove it." >>"$update_failed_file"
|
echo "${TAP} does not exist! Run \`brew untap ${TAP}\` to remove it." >>"${update_failed_file}"
|
||||||
else
|
else
|
||||||
echo "Fetching $DIR failed!" >>"$update_failed_file"
|
echo "Fetching ${DIR} failed!" >>"${update_failed_file}"
|
||||||
|
|
||||||
if [[ -f "$tmp_failure_file" ]] &&
|
if [[ -f "${tmp_failure_file}" ]] &&
|
||||||
[[ "$(<"$tmp_failure_file")" = "fatal: couldn't find remote ref refs/heads/$UPSTREAM_BRANCH_DIR" ]]
|
[[ "$(<"${tmp_failure_file}")" = "fatal: couldn't find remote ref refs/heads/${UPSTREAM_BRANCH_DIR}" ]]
|
||||||
then
|
then
|
||||||
echo "$DIR" >>"$missing_remote_ref_dirs_file"
|
echo "${DIR}" >>"${missing_remote_ref_dirs_file}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f "$tmp_failure_file"
|
rm -f "${tmp_failure_file}"
|
||||||
) &
|
) &
|
||||||
done
|
done
|
||||||
|
|
||||||
wait
|
wait
|
||||||
trap - SIGINT
|
trap - SIGINT
|
||||||
|
|
||||||
if [[ -f "$update_failed_file" ]]
|
if [[ -f "${update_failed_file}" ]]
|
||||||
then
|
then
|
||||||
onoe <"$update_failed_file"
|
onoe <"${update_failed_file}"
|
||||||
rm -f "$update_failed_file"
|
rm -f "${update_failed_file}"
|
||||||
export HOMEBREW_UPDATE_FAILED="1"
|
export HOMEBREW_UPDATE_FAILED="1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "$missing_remote_ref_dirs_file" ]]
|
if [[ -f "${missing_remote_ref_dirs_file}" ]]
|
||||||
then
|
then
|
||||||
HOMEBREW_MISSING_REMOTE_REF_DIRS="$(<"$missing_remote_ref_dirs_file")"
|
HOMEBREW_MISSING_REMOTE_REF_DIRS="$(<"${missing_remote_ref_dirs_file}")"
|
||||||
rm -f "$missing_remote_ref_dirs_file"
|
rm -f "${missing_remote_ref_dirs_file}"
|
||||||
export HOMEBREW_MISSING_REMOTE_REF_DIRS
|
export HOMEBREW_MISSING_REMOTE_REF_DIRS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for DIR in "$HOMEBREW_REPOSITORY" "$HOMEBREW_LIBRARY"/Taps/*/*
|
for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
|
||||||
do
|
do
|
||||||
[[ -d "$DIR/.git" ]] || continue
|
[[ -d "${DIR}/.git" ]] || continue
|
||||||
cd "$DIR" || continue
|
cd "${DIR}" || continue
|
||||||
|
|
||||||
TAP_VAR="$(repo_var "$DIR")"
|
TAP_VAR="$(repo_var "${DIR}")"
|
||||||
UPSTREAM_BRANCH_VAR="UPSTREAM_BRANCH$TAP_VAR"
|
UPSTREAM_BRANCH_VAR="UPSTREAM_BRANCH${TAP_VAR}"
|
||||||
UPSTREAM_BRANCH="${!UPSTREAM_BRANCH_VAR}"
|
UPSTREAM_BRANCH="${!UPSTREAM_BRANCH_VAR}"
|
||||||
CURRENT_REVISION="$(read_current_revision)"
|
CURRENT_REVISION="$(read_current_revision)"
|
||||||
|
|
||||||
PREFETCH_REVISION_VAR="PREFETCH_REVISION$TAP_VAR"
|
PREFETCH_REVISION_VAR="PREFETCH_REVISION${TAP_VAR}"
|
||||||
PREFETCH_REVISION="${!PREFETCH_REVISION_VAR}"
|
PREFETCH_REVISION="${!PREFETCH_REVISION_VAR}"
|
||||||
POSTFETCH_REVISION="$(git rev-parse -q --verify refs/remotes/origin/"$UPSTREAM_BRANCH")"
|
POSTFETCH_REVISION="$(git rev-parse -q --verify refs/remotes/origin/"${UPSTREAM_BRANCH}")"
|
||||||
|
|
||||||
# HOMEBREW_UPDATE_FORCE and HOMEBREW_VERBOSE weren't modified in subshell.
|
# HOMEBREW_UPDATE_FORCE and HOMEBREW_VERBOSE weren't modified in subshell.
|
||||||
# shellcheck disable=SC2031
|
# shellcheck disable=SC2031
|
||||||
if [[ -n "$HOMEBREW_SIMULATE_FROM_CURRENT_BRANCH" ]]
|
if [[ -n "${HOMEBREW_SIMULATE_FROM_CURRENT_BRANCH}" ]]
|
||||||
then
|
then
|
||||||
simulate_from_current_branch "$DIR" "$TAP_VAR" "$UPSTREAM_BRANCH" "$CURRENT_REVISION"
|
simulate_from_current_branch "${DIR}" "${TAP_VAR}" "${UPSTREAM_BRANCH}" "${CURRENT_REVISION}"
|
||||||
elif [[ -z "$HOMEBREW_UPDATE_FORCE" ]] &&
|
elif [[ -z "${HOMEBREW_UPDATE_FORCE}" ]] &&
|
||||||
[[ "$PREFETCH_REVISION" = "$POSTFETCH_REVISION" ]] &&
|
[[ "${PREFETCH_REVISION}" = "${POSTFETCH_REVISION}" ]] &&
|
||||||
[[ "$CURRENT_REVISION" = "$POSTFETCH_REVISION" ]]
|
[[ "${CURRENT_REVISION}" = "${POSTFETCH_REVISION}" ]]
|
||||||
then
|
then
|
||||||
export HOMEBREW_UPDATE_BEFORE"$TAP_VAR"="$CURRENT_REVISION"
|
export HOMEBREW_UPDATE_BEFORE"${TAP_VAR}"="${CURRENT_REVISION}"
|
||||||
export HOMEBREW_UPDATE_AFTER"$TAP_VAR"="$CURRENT_REVISION"
|
export HOMEBREW_UPDATE_AFTER"${TAP_VAR}"="${CURRENT_REVISION}"
|
||||||
else
|
else
|
||||||
merge_or_rebase "$DIR" "$TAP_VAR" "$UPSTREAM_BRANCH"
|
merge_or_rebase "${DIR}" "${TAP_VAR}" "${UPSTREAM_BRANCH}"
|
||||||
[[ -n "$HOMEBREW_VERBOSE" ]] && echo
|
[[ -n "${HOMEBREW_VERBOSE}" ]] && echo
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
safe_cd "$HOMEBREW_REPOSITORY"
|
safe_cd "${HOMEBREW_REPOSITORY}"
|
||||||
|
|
||||||
# HOMEBREW_UPDATE_PREINSTALL wasn't modified in subshell.
|
# HOMEBREW_UPDATE_PREINSTALL wasn't modified in subshell.
|
||||||
# shellcheck disable=SC2031
|
# shellcheck disable=SC2031
|
||||||
if [[ -n "$HOMEBREW_UPDATED" ||
|
if [[ -n "${HOMEBREW_UPDATED}" ||
|
||||||
-n "$HOMEBREW_UPDATE_FAILED" ||
|
-n "${HOMEBREW_UPDATE_FAILED}" ||
|
||||||
-n "$HOMEBREW_FAILED_FETCH_DIRS" ||
|
-n "${HOMEBREW_MISSING_REMOTE_REF_DIRS}" ||
|
||||||
-n "$HOMEBREW_UPDATE_FORCE" ||
|
-n "${HOMEBREW_UPDATE_FORCE}" ||
|
||||||
-d "$HOMEBREW_LIBRARY/LinkedKegs" ||
|
-d "${HOMEBREW_LIBRARY}/LinkedKegs" ||
|
||||||
! -f "$HOMEBREW_CACHE/all_commands_list.txt" ||
|
! -f "${HOMEBREW_CACHE}/all_commands_list.txt" ||
|
||||||
(-n "$HOMEBREW_DEVELOPER" && -z "$HOMEBREW_UPDATE_PREINSTALL") ]]
|
(-n "${HOMEBREW_DEVELOPER}" && -z "${HOMEBREW_UPDATE_PREINSTALL}") ]]
|
||||||
then
|
then
|
||||||
brew update-report "$@"
|
brew update-report "$@"
|
||||||
return $?
|
return $?
|
||||||
elif [[ -z "$HOMEBREW_UPDATE_PREINSTALL" &&
|
elif [[ -z "${HOMEBREW_UPDATE_PREINSTALL}" &&
|
||||||
-z "$HOMEBREW_QUIET" ]]
|
-z "${HOMEBREW_QUIET}" ]]
|
||||||
then
|
then
|
||||||
echo "Already up-to-date."
|
echo "Already up-to-date."
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user