249 Commits

Author SHA1 Message Date
Mike McQuaid
11116c2467 update.sh: further speed up brew update.
Tweak the logic further to make the no-op case even faster.

Before:
```
brew update  1.10s user 1.05s system 92% cpu 2.325 total
brew update --preinstall  0.60s user 0.77s system 96% cpu 1.433 total
```

After:
```
brew update  0.60s user 0.34s system 83% cpu 1.132 total
brew update --preinstall  0.29s user 0.24s system 62% cpu 0.860 total
```

These times are now fast enough to avoid any further special-casing for
`--preinstall`, roll it out to users by default and not print a message
unless we've actually found some updates.
2016-08-10 15:37:04 +01:00
Martin Afanasjew
159b0eea35 update: suppress warning about missing FETCH_HEAD
Fixes #671.
2016-08-09 21:19:30 +02:00
Mike McQuaid
2b8ea07979 update: don't recheck taps checked in the last 1m.
This is less than ideal but it gets the time on my machine down from ~6s
to ~2s when checking no taps. It still shows that we're doing way more
in `update.sh` than we need to be doing but that's a future PR.
2016-08-09 13:44:43 +01:00
Martin Afanasjew
1e9328c6e1 cmd/update.sh: fix style inconsistencies 2016-08-08 16:00:12 +02:00
AnastasiaSulyagina
be5484da8c update-report: allow Casks migration to formulae.
Closes #588.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-08-02 11:45:47 +01:00
Mike McQuaid
0d0519d48d update.sh: fix Git path.
Closes https://github.com/Homebrew/brew/issues/519
Closes https://github.com/Homebrew/homebrew-core/issues/3029
2016-07-15 19:38:27 +01:00
Mike McQuaid
a07ab8bb92 brew.{rb,sh}: move to Library/Homebrew. (#506) 2016-07-15 19:33:30 +01:00
Mike McQuaid
a02be9eea2 ENV: move to new paths. (#507)
Move some stuff formerly in `Library/ENV` around:
- Move `Library/ENV/$XCODE_VERSION` to `Library/Homebrew/env/super` as they are
  all superenv wrappers and all symlinks to the same version. We never needed
  the "separate shims for separate versions" functionality and it just adds
  confusion.
- Move `Library/ENV/pkgconfig` to `Library/Homebrew/env/pkgconfig` to get more
  things under `Library/Homebrew`
- Move `Library/ENV/scm` to `Library/scm` as these wrappers are not actually
  used by or related to superenv (or stdenv) in any way.
2016-07-15 19:03:45 +01:00
Xu Cheng
c2ece46e1b
various: don't assume non-OS X == Linux. 2016-07-14 15:41:09 +08:00
Xu Cheng
43a962a5cd update: git init for core tap as well (#510)
A temporary measure before we decide whether vendor git or not.
2016-07-14 15:39:05 +08:00
Mike McQuaid
ed1d1e51da update.sh: improve verbose output and readability. (#486)
Would have made it easier to debug
https://github.com/Homebrew/homebrew-core/issues/2804 where wasn't clear which
directory was causing the issue.
2016-07-12 19:45:49 +01:00
Dominyk Tiller
1022bcff06
update: mimic doctor permissions advice
We might as well be consistent about it, since it's not obvious to people
what the next step is after we've pointed out the directory isn't writable.

Fixes #476.
2016-07-10 12:41:08 +01:00
Mike McQuaid
86b1df96b9 Autoupdate tweaks (#442)
* Don't infinitely recurse `brew update --preinstall`.

This could happen when trying to `brew install git` inside `brew update
--preinstall`.

* update.sh: cache Git PATH.

We don’t need to look it up from superenv every time; this is slow.

* update.sh: print message before preinstall updates.

* update.sh: verbose output fetch directory.

This aids reading `brew update --verbose --debug` output.

* update.sh: skip taps without formulae on preinstall.

We don’t need to update them as we’re not invoking them.

* update.sh: don't force update-report on developer preinstall.

This is too slow.
2016-07-07 10:24:37 +01:00
Martin Afanasjew
d4f5f0cec7 brew.sh: rename 'chdir' to 'safe_cd'
This is inspired by `safe_system` with basically the same implication
(fail on error), making the name a lot less confusing and avoiding a
clash with the `chdir` function previously defined in `bin/brew`.

Closes #414.

Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
2016-06-29 13:38:50 +02:00
Mike McQuaid
62dd4b14ba update.sh: quieten checkout. 2016-06-16 10:57:46 +01:00
Mike McQuaid
e1f0dec41e update.sh: developers always run update-report.
As they may use e.g. `git pull` which may result in them having formulae
that aren't migrated (and they mind less about the slight slowdown).
2016-06-12 18:28:08 +02:00
ilovezfs
2cd81e5051 update: pop the stash more quietly
git stash pop -q will print "Already up-to-date!" if untracked changes
are being poppped. This quiets it down unless verbose is set.

Closes #320.

Signed-off-by: ilovezfs <ilovezfs@icloud.com>
2016-06-05 07:55:35 -07:00
Mike McQuaid
8a217dd420 update: tweak stash/checkout behavior. (#312)
Always pop stashed changes for Homebrew developers and only checkout
original branches for them (to avoid users who don't understand Git
ending up "stuck" on branches).
2016-06-03 14:12:36 +01:00
Xu Cheng
77836cfb3f fix shellcheck complaint 2016-05-13 14:41:29 +08:00
Xu Cheng
6eb2287221 move git shell function to brew.sh
git is also used in analytics.sh
2016-05-13 14:40:14 +08:00
Xu Cheng
92934db202 move brew shell function to brew.sh 2016-05-13 14:37:18 +08:00
Xu Cheng
1b6a200809 update: use lock
Closes #181.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-05-12 15:36:46 +08:00
Martin Afanasjew
500f9eada8 update: fix hyphen counting (legacy tap renaming)
Fix regression introduced in fafe8f0f53bf91fc41f016b5c2af41ca712783f7.
Counting the number of hyphens in a string cannot be done in a single
expression, thus split this and introduce another local variable.

Fixes #227.
2016-05-09 21:00:26 +02:00
Martin Afanasjew
93e0f4f946 update: remove stray comma (legacy tap renaming)
Fix regression introduced in fafe8f0f53bf91fc41f016b5c2af41ca712783f7.
2016-05-09 21:00:09 +02:00
Mike McQuaid
70096f8e91 update.sh: abort rebase and merge.
`brew update` can cause these so `brew update` should repair these.
2016-05-03 15:28:00 +01:00
Mike McQuaid
60e3737f17 update: improve some edge cases.
- When running `brew update` and there’s been no changes from upstream
on any repositories there’s no need to call the (relatively) slow `brew
update-report` when we already know what it will say (“Already up-to
date.”).
- When any`git fetch`es fail then throw out an error at the end of the
output and produce a failing exit code (closes #65).
2016-05-03 14:24:41 +01:00
Mike McQuaid
f288b66fcb update.sh: remove GIT_ASKPASS=false.
This doesn't work as expected and causes confusing user errors.

References #95.
2016-05-03 09:04:23 +01:00
Xu Cheng
67944c2f2d update: escape ? in the help flag list
Otherwise it will match any character
2016-05-02 21:04:30 +08:00
Xu Cheng
3b40dcedf8 update: more help flag (#180)
To be synced with the help flag list in brew.rb
2016-05-02 17:58:41 +08:00
Mike McQuaid
2921795668 update: rebase (rather than merge) by default.
We want to always avoid merge commits being committed to Homebrew so
this feels like a better fit.
2016-04-22 10:06:59 +01:00
Mike McQuaid
891dcc7c27 update: use official GitHub SHA API. (#75)
This is coming out of preview shortly so use the new API content-type.
2016-04-12 11:12:23 +01:00
Mike McQuaid
4a7cd160c3 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.
2016-04-11 09:31:50 +01:00
Max Nordlund
fa1fd70a37 Add all the top level comments 2016-04-10 22:59:25 +02:00
Max Nordlund
b21f699ff2 Implement the brew help command
This is also used by `brew <cmd> --help`. The basic idea is to have the
documentation as a top level comment in each command file. To find these
comments, they have to be like this `#:`.

This is also used by the `brew man` command to keep the documentation
DRY, and for that there are now a header and footer for the man page.
2016-04-10 22:59:24 +02:00
Martin Afanasjew
e747648c53 always prefer HOMEBREW_CURL over plain 'curl' 2016-04-07 08:25:41 +02:00
Mike McQuaid
77611bafb1 Make Homebrew user agent consistent, use a slash.
Generally it seems user agents are all `software/version` but ours is
not. Also, set the user agent in a way that it's shared between Bash
and Ruby code.

Closes https://github.com/Homebrew/legacy-homebrew/pull/50480.
2016-04-04 12:18:21 +01:00
Xu Cheng
edf000e4cd Core/formula separation Part 2(b)
* move shell completion scripts to where can be auto picked up

Let's use switching new remote as opportunity to put shell completion
scripts to where they should be and avoid git conflict during the process.

* add Library/Formula and Library/Aliases symlinks

Formulae and Aliases has been relocated to homebrew/core tap.
The symlinks are pointed to new location to keep backward compatibility.

* remove formula_renames and tap_migrations

They have been replaced by the json files in the core tap.

* update: set new remote

* bump Homebrew version to 0.9.9
2016-04-03 18:34:17 +08:00
Xu Cheng
5560f5550d git: check homebrew/core existence before installing brewed git 2016-04-02 21:51:36 +08:00
Xu Cheng
99155c3b5f update: use git from ENV/scm/git
The idea is to let `scm/git` to handle all of git location resolution
throughout Homebrew codebase.

Closes Homebrew/homebrew#50116.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-03-21 19:07:38 +08:00
Mike McQuaid
2c3a7e8c75 Fix brew update user agent.
This needs to be `Homebrew $HOMEBREW_VERSION` so we can be adequately
filtered.

Closes Homebrew/homebrew#49961.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-03-11 13:32:54 +08:00
Xu Cheng
0f6def90b7 update: shallow fetch for git_init_if_necessary
Users shouldn't need to fetch all of git history.

Closes Homebrew/homebrew#49903.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-03-09 19:47:26 +08:00
Xu Cheng
865b788e96 Revert "update: checkout branch unconditionally"
This reverts commit 0525c9eeea27eff1a6de05e7a01ec268ae07437b.
Which breaks `brew update --rebase`.
2016-03-09 17:38:46 +08:00
Xu Cheng
3a4f2c1aea update: checkout branch unconditionally 2016-03-08 20:36:19 +08:00
Xu Cheng
cad2a5620f update: passing --force to git fetch
Per document:
> -f, --force
>    When git fetch is used with <rbranch>:<lbranch> refspec, it refuses
>    to update the local branch <lbranch> unless the remote branch
>    <rbranch> it fetches is a descendant of <lbranch>. This option
>    overrides that check.
2016-03-08 20:36:19 +08:00
Mike McQuaid
3505509bae update: better handle merge conflicts.
When there are merge conflicts we fail pretty hard. This is still
possible after this commit but at least we've given Git enough pointers
to make it less likely.

Closes Homebrew/homebrew#49299.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-02-22 09:00:35 +00:00
Xu Cheng
cfc5fed7ce update: fix fork bomb caused by brew update --help
Fixes Homebrew/homebrew#49334.

Closes Homebrew/homebrew#49343.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-02-19 17:28:37 +08:00
ilovezfs
8e6c3ab039 update: always checkout master.
This should help to prevent situations where a user accidentally ends up
"stranded" in a branch indefinitely.

Additionally, the stash is never popped automatically at the end of a
successful update, but the stash-pop message is printed if something is
stashed.

When an interrupt occurs, the original behavior is still in place
(switch back to the old branch and revision, and pop the stash), though
this could be changed as well.

This commit modifies the behavior of both `brew update` and
"update-bash.sh" in the manner described above.

The idea for this approach is from Mike McQuaid.

Issue Homebrew/homebrew#48812

Closes Homebrew/homebrew#48993.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-02-18 10:44:14 +00:00
Mike McQuaid
3ac1c7b653 update: use GitHub API to avoid unneeded fetches.
Check to see if `HEAD` is the same as what we have locally. If it is:
don't bother to `git fetch`.

Closes Homebrew/homebrew#47888.

Closes Homebrew/homebrew#49219.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-02-18 10:43:10 +00: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