-
-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto-update when running brew install/upgrade. #50
Conversation
|
Yes, I'm OK with that. Something I forgot to do is to add an additional header letting people know that we've autoupdated if there are any changes. |
Would you save the update summary and dump it at the end of the install or just leave it at the top? |
Leave it at the top. |
# shellcheck source=/dev/null | ||
source "$HOMEBREW_LIBRARY/Homebrew/cmd/update.sh" | ||
HOMEBREW_PRECOMMAND="homebrew-update --preinstall" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be a bit cleaner to package this as a function like so:
update-preinstall() {
[[ -n "$HOMEBREW_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
}
Then use that further down below, e.g.:
{ update-preinstall; "homebrew-$HOMEBREW_COMMAND" "$@"; exit $?; }
To me that not only looks cleaner, but also clearer. It also avoids an unquoted variable expansion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@UniqMartin Sounds good. Does that still avoid the "file updated under it" issue, yeh?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that still avoid the "file updated under it" issue, yeh?
Yes, it does. The function has already been completely parsed by the time it is executed.
Addressed comments. |
Will merge this tomorrow if there are no objections. |
Just for my own clarity, what is the knob that prevents an auto-update from happening? (In the legacy thread from which this arose, there seemed to be general agreement that such a knob should exist.) |
@chdiza The current state of the code is that this is an opt-in feature. Once this is merged, you would have to set |
@UniqMartin Thanks. I had scanned the code looking for the knob, and my eyes must have skipped right over that shellvar. |
I'll add |
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.
Added the |
brew tests
with your changes locally?Follows on from Homebrew/legacy-homebrew#50192.
The main changes from there:
brew.sh
was updated while runningbrew edit
workflow for whenHOMEBREW_DEVELOPER
is setHOMEBREW_AUTO_UPDATE
is set (so I can test it locally and see how annoying it is to e.g. run on every command).CC @UniqMartin @xu-cheng @bfontaine @apjanke on what would be required for this to be merged as-is (disabled by default).