diff options
| author | Mike McQuaid | 2016-07-07 10:24:37 +0100 |
|---|---|---|
| committer | GitHub | 2016-07-07 10:24:37 +0100 |
| commit | 86b1df96b9a439c9a31556c0e9fd6c297e4f6646 (patch) | |
| tree | 5d2ea5dc345b68fbb8226f984e0ecd5adabf2726 /Library | |
| parent | 32f7e738ecfd84e1d8a063f9af332fdc320dfb7d (diff) | |
| download | brew-86b1df96b9a439c9a31556c0e9fd6c297e4f6646.tar.bz2 | |
Autoupdate tweaks (#442)
* Don't infinitely recurse `brew update --preinstall`.
This could happen when trying to `brew install git` inside `brew update
--preinstall`.
* update.sh: cache Git PATH.
We don’t need to look it up from superenv every time; this is slow.
* update.sh: print message before preinstall updates.
* update.sh: verbose output fetch directory.
This aids reading `brew update --verbose --debug` output.
* update.sh: skip taps without formulae on preinstall.
We don’t need to update them as we’re not invoking them.
* update.sh: don't force update-report on developer preinstall.
This is too slow.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cmd/update.sh | 32 | ||||
| -rw-r--r-- | Library/brew.sh | 1 |
2 files changed, 31 insertions, 2 deletions
diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index aafae7240..c32556583 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -9,6 +9,16 @@ # shellcheck source=/dev/null source "$HOMEBREW_LIBRARY/Homebrew/utils/lock.sh" +# Replaces the function in Library/brew.sh to cache the Git executable to +# provide speedup when using Git repeatedly (as update.sh does). +git() { + if [[ -z "$GIT_EXECUTABLE" ]] + then + GIT_EXECUTABLE="$("$HOMEBREW_LIBRARY/ENV/scm/git" --homebrew=print-path)" + fi + "$GIT_EXECUTABLE" "$@" +} + git_init_if_necessary() { if [[ -n "$HOMEBREW_OSX" ]] then @@ -255,7 +265,7 @@ homebrew-update() { --debug) HOMEBREW_DEBUG=1;; --merge) HOMEBREW_MERGE=1 ;; --simulate-from-current-branch) HOMEBREW_SIMULATE_FROM_CURRENT_BRANCH=1 ;; - --preinstall) HOMEBREW_UPDATE_PREINSTALL=1 ;; + --preinstall) export HOMEBREW_UPDATE_PREINSTALL=1 ;; --*) ;; -*) [[ "$option" = *v* ]] && HOMEBREW_VERBOSE=1; @@ -286,10 +296,16 @@ EOS odie "$HOMEBREW_REPOSITORY must be writable!" fi + if [[ -n "$HOMEBREW_UPDATE_PREINSTALL" ]] + then + echo "Checking for Homebrew updates..." + fi + if ! git --version >/dev/null 2>&1 then # we cannot install brewed git if homebrew/core is unavailable. [[ -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] && brew install git + unset GIT_EXECUTABLE if ! git --version >/dev/null 2>&1 then odie "Git must be installed and in your PATH!" @@ -331,6 +347,13 @@ EOS UPSTREAM_BRANCH="$(upstream_branch)" # the refspec ensures that the default upstream branch gets updated ( + if [[ -n "$HOMEBREW_UPDATE_PREINSTALL" ]] + then + # Skip taps without formulae. + FORMULAE="$(find "$DIR" -maxdepth 1 \( -name '*.rb' -or -name 'Formula' -or -name 'HomebrewFormula' \) -print -quit)" + [[ -z "$FORMULAE" ]] && exit + fi + UPSTREAM_REPOSITORY_URL="$(git config remote.origin.url)" if [[ "$UPSTREAM_REPOSITORY_URL" = "https://github.com/"* ]] then @@ -352,6 +375,11 @@ EOS exit fi + if [[ -n "$HOMEBREW_VERBOSE" ]] + then + echo "Fetching $DIR..." + fi + if [[ -n "$HOMEBREW_UPDATE_PREINSTALL" ]] then git fetch --force "${QUIET_ARGS[@]}" origin \ @@ -386,7 +414,7 @@ EOS if [[ -n "$HOMEBREW_UPDATED" || -n "$HOMEBREW_UPDATE_FAILED" || - -n "$HOMEBREW_DEVELOPER" ]] + (-n "$HOMEBREW_DEVELOPER" && -z "$HOMEBREW_UPDATE_PREINSTALL") ]] then brew update-report "$@" return $? diff --git a/Library/brew.sh b/Library/brew.sh index b3315a301..5381dd70d 100644 --- a/Library/brew.sh +++ b/Library/brew.sh @@ -232,6 +232,7 @@ report-analytics-screenview-command update-preinstall() { [[ -n "$HOMEBREW_AUTO_UPDATE" ]] || return [[ -z "$HOMEBREW_NO_AUTO_UPDATE" ]] || return + [[ -z "$HOMEBREW_UPDATE_PREINSTALL" ]] || return if [[ "$HOMEBREW_COMMAND" = "install" || "$HOMEBREW_COMMAND" = "upgrade" ]] then |
