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.
This commit is contained in:
parent
0382134cf8
commit
4a7cd160c3
@ -4,6 +4,13 @@ require "formulary"
|
|||||||
require "descriptions"
|
require "descriptions"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
|
def update_preinstall_header
|
||||||
|
@header_already_printed ||= begin
|
||||||
|
ohai "Auto-updated Homebrew!" if ARGV.include?("--preinstall")
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def update_report
|
def update_report
|
||||||
install_core_tap_if_necessary
|
install_core_tap_if_necessary
|
||||||
|
|
||||||
@ -17,6 +24,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
if initial_revision != current_revision
|
if initial_revision != current_revision
|
||||||
|
update_preinstall_header
|
||||||
puts "Updated Homebrew from #{shorten_revision(initial_revision)} to #{shorten_revision(current_revision)}."
|
puts "Updated Homebrew from #{shorten_revision(initial_revision)} to #{shorten_revision(current_revision)}."
|
||||||
updated = true
|
updated = true
|
||||||
end
|
end
|
||||||
@ -37,13 +45,14 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
unless updated_taps.empty?
|
unless updated_taps.empty?
|
||||||
|
update_preinstall_header
|
||||||
puts "Updated #{updated_taps.size} tap#{plural(updated_taps.size)} " \
|
puts "Updated #{updated_taps.size} tap#{plural(updated_taps.size)} " \
|
||||||
"(#{updated_taps.join(", ")})."
|
"(#{updated_taps.join(", ")})."
|
||||||
updated = true
|
updated = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if !updated
|
if !updated
|
||||||
puts "Already up-to-date."
|
puts "Already up-to-date." unless ARGV.include?("--preinstall")
|
||||||
elsif hub.empty?
|
elsif hub.empty?
|
||||||
puts "No changes to formulae."
|
puts "No changes to formulae."
|
||||||
else
|
else
|
||||||
|
@ -213,7 +213,14 @@ pull() {
|
|||||||
|
|
||||||
trap '' SIGINT
|
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
|
trap - SIGINT
|
||||||
}
|
}
|
||||||
@ -231,6 +238,7 @@ homebrew-update() {
|
|||||||
--debug) HOMEBREW_DEBUG=1;;
|
--debug) HOMEBREW_DEBUG=1;;
|
||||||
--rebase) HOMEBREW_REBASE=1 ;;
|
--rebase) HOMEBREW_REBASE=1 ;;
|
||||||
--simulate-from-current-branch) HOMEBREW_SIMULATE_FROM_CURRENT_BRANCH=1 ;;
|
--simulate-from-current-branch) HOMEBREW_SIMULATE_FROM_CURRENT_BRANCH=1 ;;
|
||||||
|
--preinstall) HOMEBREW_UPDATE_PREINSTALL=1 ;;
|
||||||
--*) ;;
|
--*) ;;
|
||||||
-*)
|
-*)
|
||||||
[[ "$option" = *v* ]] && HOMEBREW_VERBOSE=1;
|
[[ "$option" = *v* ]] && HOMEBREW_VERBOSE=1;
|
||||||
@ -316,11 +324,21 @@ EOS
|
|||||||
--header "If-None-Match: \"$UPSTREAM_BRANCH_LOCAL_SHA\"" \
|
--header "If-None-Match: \"$UPSTREAM_BRANCH_LOCAL_SHA\"" \
|
||||||
"https://api.github.com/repos/$UPSTREAM_REPOSITORY/commits/$UPSTREAM_BRANCH")"
|
"https://api.github.com/repos/$UPSTREAM_REPOSITORY/commits/$UPSTREAM_BRANCH")"
|
||||||
[[ "$UPSTREAM_SHA_HTTP_CODE" = "304" ]] && exit
|
[[ "$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
|
fi
|
||||||
|
|
||||||
git fetch --force "${QUIET_ARGS[@]}" origin \
|
if [[ -n "$HOMEBREW_UPDATE_PREINSTALL" ]]
|
||||||
"refs/heads/$UPSTREAM_BRANCH:refs/remotes/origin/$UPSTREAM_BRANCH" || \
|
then
|
||||||
odie "Fetching $DIR failed!"
|
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
|
done
|
||||||
|
|
||||||
|
@ -230,6 +230,19 @@ then
|
|||||||
& disown
|
& disown
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
update-preinstall() {
|
||||||
|
[[ -n "$HOMEBREW_AUTO_UPDATE" ]] || return
|
||||||
|
[[ -z "$HOMEBREW_NO_AUTO_UPDATE" ]] || return
|
||||||
|
|
||||||
|
if [[ "$HOMEBREW_COMMAND" = "install" || "$HOMEBREW_COMMAND" = "upgrade" ]]
|
||||||
|
then
|
||||||
|
# Hide shellcheck complaint:
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source "$HOMEBREW_LIBRARY/Homebrew/cmd/update.sh"
|
||||||
|
homebrew-update --preinstall
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [[ -n "$HOMEBREW_BASH_COMMAND" ]]
|
if [[ -n "$HOMEBREW_BASH_COMMAND" ]]
|
||||||
then
|
then
|
||||||
# source rather than executing directly to ensure the entire file is read into
|
# source rather than executing directly to ensure the entire file is read into
|
||||||
@ -240,9 +253,9 @@ then
|
|||||||
# Hide shellcheck complaint:
|
# Hide shellcheck complaint:
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
source "$HOMEBREW_BASH_COMMAND"
|
source "$HOMEBREW_BASH_COMMAND"
|
||||||
{ "homebrew-$HOMEBREW_COMMAND" "$@"; exit $?; }
|
{ update-preinstall; "homebrew-$HOMEBREW_COMMAND" "$@"; exit $?; }
|
||||||
else
|
else
|
||||||
# Unshift command back into argument list (unless argument list was empty).
|
# Unshift command back into argument list (unless argument list was empty).
|
||||||
[[ "$HOMEBREW_ARG_COUNT" -gt 0 ]] && set -- "$HOMEBREW_COMMAND" "$@"
|
[[ "$HOMEBREW_ARG_COUNT" -gt 0 ]] && set -- "$HOMEBREW_COMMAND" "$@"
|
||||||
exec "$HOMEBREW_RUBY_PATH" -W0 "$HOMEBREW_LIBRARY/brew.rb" "$@"
|
{ update-preinstall; exec "$HOMEBREW_RUBY_PATH" -W0 "$HOMEBREW_LIBRARY/brew.rb" "$@"; }
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user