Also, rename the existing updater to `update-ruby` to allow using as
a fallback. It will eventually be removed.
ClosesHomebrew/homebrew#49109.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Abbreviations will be longer if needed to preserve uniqueness.
This makes it more consistent with `git rev-parse --short`,
https://github.com/Homebrew/homebrew/commits, etc.
For example, instead of:
Updated Homebrew from 40d1e9c2 to 90b9bdf4.
We see:
Updated Homebrew from 40d1e9c to 90b9bdf.
See 0c48248b6555353c8d60b61973639c8423ce586c for the original
introduction of eight-character abbreviations.
This only affects the behavior of `brew update` while being on a branch
`feature` that doesn't track the upstream branch. For simplicity, the
upstream branch is assumed to be called `master` (`@upstream_branch` in
the code). Consider the following simplified commit history:
master origin/master (current state of remote)
| |
A---B---C---D---E---F
\
G---H---I
|
feature (HEAD)
If `origin/master` is equal to `master` and also points at commit `C`,
then `brew update` will update both `master` and `origin/master` to `F`
and report on the changes in the range `C..F`.
However, if `origin/master` is equal to `E` because some commits have
been already fetched with `git fetch origin`, then `brew update` will
recreate `master` from `origin/master` and then pull in the commits from
the remote to update both to `F`. Because `master` gets recreated from
a younger `origin/master`, the report will only contain changes from the
range `E..F` (thus omitting the changes from `C..E`).
This commit adjusts the logic to not recreate `master` if it can be
safely fast-forwarded to `origin/master` (the common case). This fixes
the problem from the second scenario and again reports on the desired
range `C..F`.
ClosesHomebrew/homebrew#46951.
Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
Users with local changes and without a configured Git identity won't be
able to update Homebrew via `brew update`, as the update will fail when
trying to stash the local modifications with `git stash`. They will be
unable to proceed until they follow Git's advice to configure their
identity or they manage to revert their local changes.
This change always sets a commit e-mail and name, avoiding this issue. A
nice bonus is that experienced Git users can see who created the stash
commit (identifying `brew update` as the author).
FixesHomebrew/homebrew#46930.
ClosesHomebrew/homebrew#46939.
Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
Do a reset to `origin/master` and then stash but don't pop the stash
after running update (unless you were on a branch). This may be mildly
more annoying for Homebrew developers but means it's easier for our
users who don't understand Git (and particularly when they don't
understand that every tap is a separate Git repository).
ClosesHomebrew/homebrew#45825.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
There's been a few issues where users have been confused about these
errors. They may have modified stuff but we probably don't care about
telling them that unless we're debugging other issues.
ClosesHomebrew/homebrew#45373.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
There are plenty of IO operations inside Tap object, and it will be more
when implementing formula alias reverse look up(e.g. list all of alias
names for a formula). So let's cache them.
Some benchmark:
$ time brew info $(brew ruby -e 'puts Formula.tap_names') > /dev/null
Before: 6.40s user 2.42s system 96% cpu 9.134 total
After: 4.75s user 0.77s system 97% cpu 5.637 total
ClosesHomebrew/homebrew#44377.
Signed-off-by: Xu Cheng <xucheng@me.com>
For update, all formula loading need to be secured by `rescue`.
Otherwise it's easy to crash `brew update` for vasty reasons, e.g.
new Formula DSL.
ClosesHomebrew/homebrew#43353.
Signed-off-by: Xu Cheng <xucheng@me.com>
If the user's working copy is *not* on the 'master' branch, the revision
recorded after the update to the 'master' branch is not the one of the
updated 'master' branch but that of whatever the user's current branch
is. This tends to be not very helpful.
This change records the revision *after* the update to the 'master'
branch, but *before* switching back to the user's current branch prior
to the update, effectively causing the report to show changes to the
'master' branch.
ClosesHomebrew/homebrew#42074.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This was added in 3a7a3619f7016c75c3e53e944221bf7f6354a63b to make the
tests pass, but this method is now stubbed out in the tests, so we can
assume $? will be non-nil.