123 Commits

Author SHA1 Message Date
Ruoyu Zhong
1b62371455
cmd/update: use ShellCommand 2024-07-15 14:48:37 -04:00
Mike McQuaid
5987c5c1d0
Add stub Ruby commands for all Bash commands.
This gets us pretty similar (but easier to manage) manpage output but
much nicer completions etc. for all these commands.
2024-07-14 23:12:53 -04:00
Mike McQuaid
775c4eedd7 Promote update-bash to the default updater.
Also, rename the existing updater to `update-ruby` to allow using as
a fallback. It will eventually be removed.

Closes Homebrew/homebrew#49109.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-02-15 08:54:03 +00:00
Joseph Frazier
91d4ba7158 update: abbreviate hashes to at least 7 characters
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.
2016-01-08 15:56:43 +01:00
Baptiste Fontaine
9f1442db14 doctor: move code away from cmd/
Closes Homebrew/homebrew#47665.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
2016-01-05 14:33:06 +01:00
Martin Afanasjew
cc632acd07 update: avoid unnecessarily recreating 'master'
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`.

Closes Homebrew/homebrew#46951.

Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
2016-01-04 16:25:32 +01:00
Martin Afanasjew
9789726fff update: make stashing local changes more robust
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).

Fixes Homebrew/homebrew#46930.

Closes Homebrew/homebrew#46939.

Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
2015-12-13 22:18:14 +01:00
Mike McQuaid
d36d88edf2 Allow taps to link manpages.
A blocker for https://github.com/caskroom/homebrew-cask/pull/15381
being merged.

Closes Homebrew/homebrew#46795.
2015-12-09 09:09:26 +00:00
Xu Cheng
fe032e3e96 avoid using FORMULA_RENAMES directly 2015-12-09 16:56:59 +08:00
Mike McQuaid
bf2315b1f4 Use (installed) and emoji ticks consistently.
Across info, search and update.

Closes Homebrew/homebrew#45131.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-12-07 14:56:30 +00:00
Mike McQuaid
fe8a0569ca update: always reset to origin/master.
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).

Closes Homebrew/homebrew#45825.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-12-07 13:37:27 +00:00
Xu Cheng
48950f2cc0 centralize the logic of handling homebrew- in Tap.fetch
Closes Homebrew/homebrew#46537.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-12-03 13:46:59 +08:00
Alex Dunn
745ec8f7c9 cmd/update: check before tapping
Follow-up to ea6c8f7e2dc8f1adf8df9065468d0b37047d4a46
2015-11-09 07:30:02 -08:00
Xu Cheng
82689d81f7 use Tap#install 2015-11-09 15:34:20 +08:00
Xu Cheng
ffbb1828a2 update: always rescue formula loading
Closes Homebrew/homebrew#45676.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-11-04 20:44:28 +08:00
Mike McQuaid
8ea9903a99 update: use git stash silently.
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.

Closes Homebrew/homebrew#45373.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-10-27 10:45:23 -06:00
Martin Afanasjew
7044bf7bbf update: report tap updates and improve wording
Closes Homebrew/homebrew#43468.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-10-16 09:12:29 +01:00
Martin Afanasjew
0114a26483 update: highlight installed formulae in report
Closes Homebrew/homebrew#44335.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-10-15 08:55:47 +01:00
Vlad Shablinsky
e04a463f11 update: allow updating from local branch
Closes Homebrew/homebrew#44893.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-10-14 14:01:27 +01:00
Xu Cheng
3b520cf195 cache taps
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

Closes Homebrew/homebrew#44377.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-09-30 16:25:30 +08:00
Xu Cheng
e66cb91702 update: add permissions check
Closes Homebrew/homebrew#42048

Closes Homebrew/homebrew#44434.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-09-30 13:54:04 +08:00
Misty De Meo
520b8496d4 Fix brew update for taps with non-master branches
Fixes Homebrew/homebrew#43865.
2015-09-19 00:52:23 -07:00
Mike McQuaid
b1ff9c42d6 update: fix when HEAD doesn't exist.
e.g. when it's a detached `HEAD` through checking out a commit rather
than a branch.
2015-09-11 11:00:27 +01:00
Dan Martinez
8374374168 Improve description searching and add a cache.
Closes Homebrew/homebrew#42281.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-09-08 15:23:37 +01:00
Josh Hagins
f431e543a5 update: explicitly no-ff merge and rebase.
This overrides user configuration which may do otherwise.

Closes Homebrew/homebrew#41570.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-09-07 12:05:20 +01:00
Xu Cheng
03f7e19ca6 update: ensure git is installed 2015-09-02 15:24:53 +08:00
Xu Cheng
3458b99d6e update: secure formula loading in rename
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.

Closes Homebrew/homebrew#43353.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-08-28 17:15:18 +08:00
Martin Afanasjew
1288e3110d update: always report changes to branch 'master'
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.

Closes Homebrew/homebrew#42074.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-08-27 13:53:28 +01:00
Baptiste Fontaine
e779be1453 update: #each.map is redundant 2015-08-25 09:45:21 +02:00
Xu Cheng
a88c40b8c8 core file style update 2015-08-22 13:15:33 +08:00
Xu Cheng
62d1636144 update: only update renamed when necessary 2015-08-20 20:12:02 +08:00
Vlad Shablinsky
e4480cf6bf update: add formula renames to report 2015-08-20 19:55:35 +08:00
Baptiste Fontaine
8ba0fb9fcf unnecessary calls to .select simplified
These are minor perf optimizations.

Closes Homebrew/homebrew#43028.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
2015-08-18 00:18:22 +02:00
Xu Cheng
3c45e1e81d update: only compute tapd_basename when necessary 2015-08-15 18:32:22 +08:00
Vlad Shablinsky
f88f2b7054 update tabs only if core formula installed
Closes Homebrew/homebrew#42745.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-08-10 16:09:26 +01:00
Vlad Shablinsky
0b854adbf4 update: fix load_tap_migrations 2015-08-10 16:09:26 +01:00
Vlad Shablinsky
6b0927944a update: handle renames on update 2015-08-10 13:57:59 +01:00
Xu Cheng
3c8a19777d update: handle more exceptions
Closes Homebrew/homebrew#42558.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-08-07 13:42:31 +08:00
Xu Cheng
09e0bcf1fc update: loading core files at the beginning
This should help to prevent similar situation of Homebrew/homebrew#42553 happening in the
future.
2015-08-06 22:51:36 +08:00
BrewTestBot
13d544e11e Core files style updates.
Closes Homebrew/homebrew#42354.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-08-03 13:22:35 +01:00
Xu Cheng
a9b9c5ade7 Tap: allow enumerate non-git taps
Also add a `Tap#git?` method to indicate whether the tap is a git
repository.

Closes Homebrew/homebrew#42264.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-07-30 21:28:52 +08:00
Mike McQuaid
151890148c update: fix --rebase 2015-07-09 23:50:55 +01:00
Mike McQuaid
b11ae2abdc update: stash save/pop uncommitted changes.
Also:
- return to your previous branch after `brew update`.

Closes Homebrew/homebrew#38568.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-07-09 12:33:31 +01:00
Xu Cheng
44383fecb8 (un)tap/update/readall: use Tap class 2015-06-11 15:28:29 +08:00
Xu Cheng
023230cb6a update: only display version changed formulae
Closes Homebrew/homebrew#40090.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-06-02 17:24:05 +08:00
Jack Nagel
efd52da101 Remove dead code 2015-05-27 21:57:41 -04:00
Xu Cheng
171c3dd2d9 tap/untap/update/prune: remove obsolete method, add migrate_taps 2015-05-27 13:53:40 +08:00
Jack Nagel
fef8b0871d Remove obsolete nil guard
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.
2014-09-18 21:56:48 -05:00
Jack Nagel
56dd575f96 Pass command and arg list into ErrorDuringExecution constructor 2014-09-18 20:32:50 -05:00
Jack Nagel
f40650ecd0 Set the remote config manually
See 5cd6b35 and 8eefd4e.
2014-08-12 01:46:12 -05:00