diff options
| author | Mike McQuaid | 2016-04-11 09:31:50 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2016-04-11 09:31:50 +0100 |
| commit | 4a7cd160c31969b79979ae9bd20afcf82d9513c0 (patch) | |
| tree | 37f16512cb0f4fee1237e72310722c67e99af69c /Library/Homebrew/cmd/update.sh | |
| parent | 0382134cf87321166fb8f03223e21b1d242ad7cb (diff) | |
| download | brew-4a7cd160c31969b79979ae9bd20afcf82d9513c0.tar.bz2 | |
Auto-update when running `brew install`/`upgrade`.
Also, slightly tweak the behavior of `brew update` in this case so that
it doesn't print annoying output and still allows the `brew edit` flow
for people with `HOMEBREW_DEVELOPER` set.
Diffstat (limited to 'Library/Homebrew/cmd/update.sh')
| -rw-r--r-- | Library/Homebrew/cmd/update.sh | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index a0c7cc7e7..a36b25fb0 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -213,7 +213,14 @@ pull() { trap '' SIGINT - pop_stash_message + if [[ -n "$HOMEBREW_DEVELOPER" ]] && + [[ "$INITIAL_BRANCH" != "$UPSTREAM_BRANCH" && -n "$INITIAL_BRANCH" ]] + then + git checkout "${QUIET_ARGS[@]}" "$INITIAL_BRANCH" + pop_stash + else + pop_stash_message + fi trap - SIGINT } @@ -231,6 +238,7 @@ homebrew-update() { --debug) HOMEBREW_DEBUG=1;; --rebase) HOMEBREW_REBASE=1 ;; --simulate-from-current-branch) HOMEBREW_SIMULATE_FROM_CURRENT_BRANCH=1 ;; + --preinstall) HOMEBREW_UPDATE_PREINSTALL=1 ;; --*) ;; -*) [[ "$option" = *v* ]] && HOMEBREW_VERBOSE=1; @@ -316,11 +324,21 @@ EOS --header "If-None-Match: \"$UPSTREAM_BRANCH_LOCAL_SHA\"" \ "https://api.github.com/repos/$UPSTREAM_REPOSITORY/commits/$UPSTREAM_BRANCH")" [[ "$UPSTREAM_SHA_HTTP_CODE" = "304" ]] && exit + elif [[ -n "$HOMEBREW_UPDATE_PREINSTALL" ]] + then + # Don't try to do a `git fetch` that may take longer than expected. + exit fi - git fetch --force "${QUIET_ARGS[@]}" origin \ - "refs/heads/$UPSTREAM_BRANCH:refs/remotes/origin/$UPSTREAM_BRANCH" || \ - odie "Fetching $DIR failed!" + if [[ -n "$HOMEBREW_UPDATE_PREINSTALL" ]] + then + git fetch --force "${QUIET_ARGS[@]}" origin \ + "refs/heads/$UPSTREAM_BRANCH:refs/remotes/origin/$UPSTREAM_BRANCH" 2>/dev/null + else + git fetch --force "${QUIET_ARGS[@]}" origin \ + "refs/heads/$UPSTREAM_BRANCH:refs/remotes/origin/$UPSTREAM_BRANCH" || \ + odie "Fetching $DIR failed!" + fi ) & done |
