91 Commits

Author SHA1 Message Date
Mike McQuaid
bf42959609 Revert "Revert "Test officially supported cmd taps. (#390)""
This reverts commit dba1958bd79c1c9d18f215dfc2b806ea62edd1c8.
2016-07-04 17:05:37 +01:00
Martin Afanasjew
dba1958bd7 Revert "Test officially supported cmd taps. (#390)"
This reverts commit 252c701c59227c385ef6178fe99523cca8c843bb.

Taps installed prior to running the test suite are not visible to the
test suite as most Homebrew paths are redefined as to not mess up the
local installation.
2016-07-04 17:41:14 +02:00
Mike McQuaid
252c701c59 Test officially supported cmd taps. (#390)
All of these taps use Homebrew internal APIs (or will shortly) and we
autoinstall them all from `brew $CMD`. We should adjust our CI to ensure
that we never accidentally break these taps when making changes to core
code so that these taps can rely more on this core code rather than
having to e.g. vendor equivalent code that never changes on our end.
2016-07-04 16:08:53 +01:00
Mike McQuaid
549c86dfe2 brew.rb: check issues url properly. 2016-05-08 17:02:02 +01:00
Mike McQuaid
ddb576b582 Add support for testing generic OS.
If the environment variable HOMEBREW_TEST_GENERIC_OS is set ensure that
neither Mac nor Linux-specific code is loaded. This allows easier
testing of cross-platform code on OS X and will make it easier to port
Homebrew to platforms other than OS X and Linux.
2016-05-08 16:51:22 +01:00
Mike McQuaid
0ef21ddf87 analytics: move to a class.
Global namespaces are good to avoid when possible.
2016-05-03 14:21:08 +01:00
Mike McQuaid
00736276fe brew.rb: uninstall old Homebrew Cask. (#121)
This version is never wanted at this point and it will help Homebrew
Cask deal with the annoying errors that result from having this version
still around (some which I've already help users debug).
2016-04-21 16:36:34 +01:00
Martin Afanasjew
d9363a1559 exceptions: add reason to 'UsageError' exception
Use the `reason` attribute to be able to handle `UsageError` subclasses
more uniformly and simplify logic in `brew.rb` to handle them together.
2016-04-20 13:46:10 +02:00
Martin Afanasjew
cf3486f98a help: show command-specific help for invalid usage
Instead of always printing the generic help text, print command-specific
help if it is available and a command raised the `UsageError` exception.
Put the error message underneath the help text (was above) to avoid that
it scrolls off the screen.

Thereby fix a regression where handling the invalid usage would fail to
access `ARGV.usage` removed in c6536066dc39da653d265640c6ba6046bb5def98.
2016-04-20 13:46:10 +02:00
Martin Afanasjew
557ad956fd help: refactor (again) and fix code style issues
Turns out making `empty_argv` a boolean argument for `Homebrew.help` was
not the best idea and having command-to-path mapping and help extraction
in a single method is not flexible enough.

Also only complain about missing help text when `HOMEBREW_DEVELOPER=1`
and otherwise just print the generic help text.
2016-04-20 13:46:10 +02:00
Martin Afanasjew
980001341d brew.rb: fix Ruby syntax warning
Library/brew.rb:108: warning: `*' interpreted as argument prefix
2016-04-20 01:38:00 +02:00
Martin Afanasjew
f15b631875 brew.rb: don't show help for 'brew <command> help'
Showing help makes sense for `brew help <command>`, but showing it for
`brew <command> help` is undesirable and prevents all commands from
accepting a named argument `help` (formula, tap, file name, etc.).

All other help flags are still detected before *and* after the command.

Closes #103.

Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
2016-04-18 00:52:33 +02:00
Martin Afanasjew
3503806e77 help: handle help output (move from 'brew.rb')
Keep the footprint of `brew.rb` small. Handle fetching/displaying an
appropriate help text (taking into account various external conditions)
in the `help` command.
2016-04-18 00:52:32 +02:00
Martin Afanasjew
0382134cf8 brew.rb: adjust behavior for undocumented commands
Don't exit with a non-zero status code just because an internal command
happens to be undocumented. Also print the generic help in these cases
to provide some help (including a reference to the man page).
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
Mike McQuaid
c5cd206169 brew.rb: report some exceptions. 2016-04-04 12:27:47 +01:00
Xu Cheng
2bb30fc5f0 --version/config: show core tap information 2016-04-02 21:51:36 +08:00
Xu Cheng
ce7b32cec8 add HOMEBREW_ENV_PATH internal variable
`Library/ENV` like `Library/Homebrew` is part of Homebrew basecode. It
should be able to be accessed during the `brew tests`.

By adding HOMEBREW_ENV_PATH variable, we allow test suit to locate these
codes.
2016-03-21 19:07:38 +08:00
Mike McQuaid
f6cbf7bab0 Move internal command aliases from Ruby to Bash.
This means that internal command aliases can be used for Bash commands
(such as the new, Bash-based `brew update`).

Fixes Homebrew/homebrew#49182.

Closes Homebrew/homebrew#49184.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-02-15 11:35:25 +00:00
Martin Afanasjew
27b606d928 brew.rb: remove executable bit and shebang
Because `brew.rb` should never be invoked directly, remove executable
bit and shebang to make that more obvious.

Closes Homebrew/homebrew#48816.

Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
2016-02-05 22:07:07 +01:00
Xu Cheng
12a452557d make HOMEBREW_BREW_FILE a Pathname object
Currently HOMEBREW_BREW_FILE is a String, while other of HOMEBREW_*
variables are all Pathname. This commit unifies them all as Pathname,
so it will not cause any confusion.

Closes Homebrew/homebrew#48872.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-02-06 02:52:48 +08:00
ilovezfs
604323e641 brew.rb: use $stderr for debug and errors.
Closes Homebrew/homebrew#48634.
Closes Homebrew/homebrew#48681.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-02-01 18:37:36 +00:00
Mike McQuaid
7260b35c31 config: fail when HOMEBREW_BREW_FILE is unset.
Not sure why this is happening (beyond the Chef cookbook stupidly
deciding to not call through `bin/brew`) but fail and print a scary
looking error to hope to point people in the right direction.

Closes Homebrew/homebrew#48261.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-01-27 12:49:25 +00:00
Martin Afanasjew
29d80643d2 brew.rb: don't re-export for external commands
`bin/brew` already sets up a bunch of environment variables. There's no
need to re-export them for external commands. (`HOMEBREW_LIBRARY_PATH`
and `HOMEBREW_CACHE` continue to be determined later in the Ruby code.)
2016-01-26 16:26:07 +01:00
Xu Cheng
f51587ee74 brew.rb: fix style problem
Generated by `brew style --fix Library/brew.rb`
2016-01-20 13:55:06 +08:00
Xu Cheng
27e8577f94 brew.rb: fix overeager help flag matching 2016-01-20 13:55:06 +08:00
Xu Cheng
f9b33e26e0 brew: remove duplicated logic
This is now handled by `bin/brew`
2016-01-20 13:55:06 +08:00
Mike McQuaid
6f91b429ce Move some brew.rb logic to bin/brew. 2016-01-17 19:48:02 +00:00
Xu Cheng
c4dcf8b7b2 brew: tap missing tap as normal user
Before this, `sudo brew cask` will auto install Homebrew cask as root
user. This will cause permission problem for files in `Tap` directory.

Therefore, let's check process uid and switch to normal user for tap.
As result, `sudo brew cask` will work as the same before, except tap
files will have the correct permission attributes.

Closes Homebrew/homebrew#48059.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-01-14 19:32:07 +08:00
Mike McQuaid
2392574a77 brew.rb: only print "Kernel.exit" on failures.
Also, print as a warning to STDERR and print a backtrace in debug mode.

Closes Homebrew/homebrew#47099.

Closes Homebrew/homebrew#47154.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-12-21 10:05:49 +00:00
Martin Afanasjew
233a38ac95 brew.rb: improve handling of --version/-v option
Make both `--version` and `-v` print the Homebrew version and exit, if
provided as first and sole argument. `brew --version` no longer accepts
additional arguments (they were previously ignored). Otherwise interpret
`brew -v <arguments>` as if `brew <arguments> -v` was executed instead
(no change here), but no longer print a line with the Homebrew version.

Closes Homebrew/homebrew#46790.

Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
2015-12-10 15:01:59 +01:00
Mike McQuaid
6d384a730f brew: cask is now a tap command.
So we can remove the formula installation from `brew.rb`.

Closes Homebrew/homebrew#46843.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-12-10 09:31:39 +00:00
Mike McQuaid
8d6b6a451b brew.rb: handle cask autoinstall when cask tapped.
Otherwise it would assume if `cask` was tapped it was also installed.
2015-12-08 10:41:27 +00:00
Xu Cheng
ac6b22fd69 auto install certain external commands
Closes Homebrew/homebrew#45773.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-11-09 15:34:20 +08:00
Dominyk Tiller
cfb913b2c2 brew: add more non-root-user sudo checks 2015-10-19 05:54:56 +01:00
Dominyk Tiller
aa0a22147d brew: tighten sudo checks
`reinstall` can currently be executed under sudo and has every chunk of problems
running install under sudo does when `brew` isn't root owned.

Likewise with `postinstall` which we increasingly use to create directories and
move/install files elsewhere. Using sudo there both masks deeper issues and
makes uninstall troublesome.

Closes Homebrew/homebrew#45112.

Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
2015-10-19 05:33:08 +01:00
Dominyk Tiller
5f86a60e29 brew: check xcode license status
The xcrun code is stolen right out of the INSTALL script.

Check for user agreement of the Xcode license before permitting any other brew usage to continue.
This prevents the situation where people are instructed to "please re-run as root via sudo" on brew commands.
The check can only fail when Xcode is installed & the active developer dir.

Closes Homebrew/homebrew#44974.

Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
2015-10-15 20:29:41 +01:00
Xu Cheng
ce390b9bd9 add dev-cmd folder 2015-09-12 19:15:45 +08:00
Tim D. Smith
143709e679 include git sha1 in --version output
HOMEBREW_VERSION doesn't change very often; the repository state is more
interesting.

Closes Homebrew/homebrew#41886.
2015-08-25 00:13:53 -07:00
Xu Cheng
d62095710f More core files style updates 2015-08-03 20:38:20 +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
Baptiste Fontaine
ea13d62ce0 brew: print bug report URL for internal commands only
Closes Homebrew/homebrew#42069.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
2015-07-28 20:38:13 +02:00
Xu Cheng
78a7dea3a0 add brew command
Closes Homebrew/homebrew#41034.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-07-03 14:22:38 +08:00
Baptiste Fontaine
8ef8f0f615 sudo_check: don't use a set
This is unnecessary here because we use it only once. The difference
won't be noticeable but the check is ~5 times faster now.

Closes Homebrew/homebrew#40901.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
2015-06-20 12:13:26 +02:00
Jack Nagel
72cb403a56 Move 10.11 warning to doctor, pre-install, and post-failure
Fixes Homebrew/homebrew#40778.
2015-06-16 20:02:10 -04:00
Dominyk Tiller
778c25b458 brew: warn about 10.11 unsupported
Issue a warning about Homebrew's very basic support for 10.11 at this point
in time on each run of `brew`.

Closes Homebrew/homebrew#40536.

Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
2015-06-14 18:38:55 +01:00
Misty De Meo
c72877cc82 Stop supporting Leopard
Is this really Misty?!
2015-05-14 20:58:49 -07:00
Jack Nagel
d4c8f83381 Inline error message 2015-04-21 20:46:02 -04:00
Jack Nagel
136bc02374 Simplify setting load path 2015-04-20 20:31:16 -04:00
Roberto Nibali
39ead112f3 brew.rb: fix help regex.
Don't match `help` at the end of every string because `brew installhelp`
shouldn't really be running help.

Closes Homebrew/homebrew#36559.
Closes Homebrew/homebrew#36576.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-02-06 08:19:35 +00:00