137 Commits

Author SHA1 Message Date
Markus Reiter
86bec56bf8 Make Formulary a module. 2017-02-20 13:06:23 +01:00
Alyssa Ross
ade8128a18 formulary: handle ScriptError in formula
I added a new `FormulaUnreadableError` subclass of
`FormulaUnavailableError` so existing `rescue`s of
`FormulaUnavailableError` handle this as well.

The new subclass will output the name of the formula with the error
(because this isn't always obvious from the original exception message)
followed by the original error message.

Fixes #1927.
2017-02-01 18:34:20 +00:00
Mike McQuaid
d8adae0f92 formulary: read from formula in opt prefix.
We want to prefer the newer/versioned formulae when possible but this
is preferable to a random cached formula or, worse, no formula.

This means `brew info foo` will never complain that `foo` is a missing
formula.
2017-01-09 21:42:09 +00:00
Mike McQuaid
c3a2bf34a2 tap_migrations: support renaming to/from casks.
Allow `tap_migrations` entries to have a `user/repo/formula` or
`user/repo/cask` format for migration of formulae to/from casks.
2016-12-29 13:37:28 +00:00
Mike McQuaid
85f62afae6 Merge pull request #1733 from vladshablinsky/rb_in_name
Don't drop .rb suffix for formula names
2016-12-29 12:32:12 +00:00
Uladzislau Shablinski
d091537636 Don't drop .rb suffix for formula names
Fixes #1718
2016-12-26 20:16:04 +03:00
Uladzislau Shablinski
478e4f112c formulary: call tap not formula
Fixes #1668
2016-12-14 05:07:54 +03:00
Mike McQuaid
d085a47124 Merge pull request #1646 from MikeMcQuaid/report-deprecations-to-tap
Tell people to report URL/tap deprecations to the tap.
2016-12-11 12:17:49 +00:00
Mike McQuaid
598c5e36f9 Tell people to report URL/tap deprecations to the tap.
Rather than Homebrew/brew or Homebrew/homebrew-core.
2016-12-10 13:04:14 +00:00
Mike McQuaid
8e2f0ccdc3 formulary: remap deprecated options from keg.
When reading a building a formula from a keg (rather than e.g. from
name) then the deprecation options were not remapped correctly as they
are only done in `Tab.for_formula` and not `Tab.for_keg`. Ensure that
after we’ve created the formula that the `used_options` are remapped
correctly.
2016-12-09 17:59:08 +00:00
Mike McQuaid
b32fafa82c formulary: don't warn on old formula name from keg/rack.
If there’s an old installation of e.g. `apple-gcc42` from when it was
part of `homebrew/core` then the tab will say it was from the
`homebrew/core` tap and then we’ll complain at the user (see #1459 for
an example). Instead, we only want to complain when the user actually
types in `homebrew/core/apple-gcc42` into a `brew` command.

Closes #1459.
2016-11-11 16:42:29 +00:00
Mike McQuaid
133bad9a97 formulary: migrate fully-scoped formulae names.
e.g. allow `brew install some/tap/formula` to look that formula up in
another tap if it has been migrated.

Also, add a deprecation message to point people towards the correct
naming.
2016-11-02 14:47:24 -04:00
Markus Reiter
6c6a4c9fa7 RuboCop: Style/AccessorMethodName 2016-09-24 19:28:26 +02:00
Markus Reiter
58e36c7319 Fix Style/GuardClause. 2016-09-24 12:24:35 +02:00
Markus Reiter
fe2d51e0b9 Fix Style/IfUnlessModifier. 2016-09-23 15:30:07 +02:00
Mike McQuaid
3ffb9a2f7c Fix another brew style from #971. 2016-09-19 16:28:28 +01:00
Mike McQuaid
c9d9e54de6 Fix brew style from #971. 2016-09-19 16:04:32 +01:00
Alyssa Ross
2a683f2569 upgrade, outdated: follow alias changes 2016-09-18 19:58:09 +01:00
Mike McQuaid
3982950e61 rubocop --auto-correct all hash-rocket usage. 2016-09-17 16:14:13 +01:00
Mike McQuaid
6693915399 rubocop --auto-correct all remaining files.
But remove some manual `.freeze`s on constants that shouldn't be
constants.
2016-09-17 16:14:13 +01:00
Alyssa Ross
65ee5408c3 Replace install_name/install_ref with alias_path 2016-09-05 01:19:08 +01:00
Alyssa Ross
c17664b124 Switch to hash rockets 2016-09-05 01:19:08 +01:00
Alyssa Ross
0ef3e1e0dc Preserve alias when installing formulae
Part of #567
2016-09-03 21:16:43 +01:00
Dominyk Tiller
d3b6a7a763
formulary: tweak @ translation 2016-08-29 19:48:34 +01:00
Dominyk Tiller
98155a5526
formulary: translate @ to AT for classname 2016-08-28 03:08:14 +01:00
Mike McQuaid
d0251c1abc formulary: fix to_rack for fully-scoped references
Fixes the case where I have `mysql56` installed but do
`brew uninstall foo/bar/mysql56` which isn't a valid formula.

Fixes https://github.com/Homebrew/legacy-homebrew/issues/39883.
2016-08-10 09:40:39 +01:00
Uladzislau Shablinski
63c563f970 Fix update commit for non-HEAD kegs with head spec (#644)
If we try to call `Formulary.from_keg(f, :head)` on the keg that
is not HEAD-keg itself, we don't need to update commit of
returned formula and should use just HEAD version with nil commit.

Same is true for `ARGV.resolved_formulae`
2016-08-06 16:22:12 +08:00
Uladzislau Shablinski
092d4712a1 Update commit when resolving the formula (#536) 2016-07-17 16:56:13 +08:00
Xu Cheng
3995d237dd
formulary: add missing keg.rack 2016-07-15 19:59:35 +08:00
Xu Cheng
c021f37525
add Formulary#from_keg 2016-07-15 19:57:23 +08:00
Xu Cheng
7452dcf508
ARGV#resolved_formulae: also load build options 2016-07-15 19:57:23 +08:00
Martin Afanasjew
8486f6e04d Prefer $stderr over STDERR for consistency (#304)
Prior to this change there were only 3 instances of `STD(IN|OUT|ERR)`
versus 74 instances of `$std(in|out|err)` in the Homebrew code base. The
latter variant is also strongly suggested by bbatsov's Ruby Style Guide.
2016-06-01 09:45:49 +02:00
Mike McQuaid
6ba466f5d8 Use JSON files for bottle upload data. (#166)
This means that we do not need to read formulae or evaluate Ruby at
upload time.
2016-05-28 15:54:05 +01:00
Mike McQuaid
d345483de1 formulary: fix comment typo. 2016-05-22 21:29:39 +01:00
Mike McQuaid
931e292bf1 Make bottle code cross-platform. 2016-05-08 16:51:22 +01:00
Martin Afanasjew
c3076f0b69 formulary: use FormulaClassUnavailableError
Present a more helpful error message if a formula file was loaded, but
the class(es) therein didn't match the expected formula class name.
2016-04-17 21:16:01 +02:00
Xu Cheng
a5cfc011e0 various: Homebrew/core is the core tap
Also make `Homebrew/homebrew` as an alias of this tap to keep
backward compatibility.
2016-04-02 21:51:36 +08:00
Xu Cheng
28f3dae8cd rename CoreFormulaRepository to CoreTap
Core tap will be separated from core code in the near future.
It makes sense to rename it to CoreTap.
2016-03-07 19:43:46 +08:00
Xu Cheng
b52af53e71 various: use Tap abstraction
formula_rename and tap_migrations are now handled inside Tap.

Closes Homebrew/homebrew#49549.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-02-26 17:00:17 +08:00
Xu Cheng
6ac6cb4fcd TapLoader: improve load logic
* Use `Tap#formula_dir` instead of `Tap#formula_files` to find formula
  file to have better performance and avoid caching issue.
* Change the loader logic to search name -> search alias -> search old name.
  This is more consistence with what we do when loading core formula
  file.

Closes Homebrew/homebrew#49484.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-02-24 20:51:35 +08:00
Xu Cheng
0f84b976ba move CoreFormulaRepository into separate file
For users whose local brew is at around 2015-06-11 to 2015-08-06,
running `brew update` will emit following error:

  Error: uninitialized constant Formulary::CoreFormulaRepository

This is caused by the same bug described in Homebrew/homebrew#42553.

This commit workarounds this issue and restores `brew update` compatibility
for users mentioned above.

Also cleanup legacy `require "cmd/tap"`.
2015-12-19 22:05:30 +08:00
Xu Cheng
82eb1a4c42 formulary: use CoreFormulaRepository
Let's hide implementation detail on where to find core formulae alias
directory. This will benefit future core code and formulae separation.
2015-12-19 22:05:30 +08:00
Alex Dunn
af77e8b380 Formulary: explicitly require tap
Fixes Homebrew/homebrew#46984.
2015-12-13 20:19:53 -08:00
Xu Cheng
fe032e3e96 avoid using FORMULA_RENAMES directly 2015-12-09 16:56:59 +08:00
Xu Cheng
6e92609cf4 Formulary: use same logic to handle core fully-qualified name 2015-12-09 16:56:59 +08:00
Xu Cheng
061a34b138 Formulary.core_path: use CoreFormulaRepository#formula_dir 2015-12-09 16:56:59 +08:00
Xu Cheng
b810c034b7 Formulary: use Tap#alias_dir 2015-12-09 16:56:59 +08: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
Xu Cheng
60ba8beefa Formulary.from_rack: better formula resolution strategy
The flow is as follow:
* If tap is nil(DIY install), search using name.
* If tap is found, search using full name.
* If tap is found and full name searching failed, search using name.
  This usually means the formula may be migrated to different tap.

Closes Homebrew/homebrew#44771.

Signed-off-by: Xu Cheng <xucheng@me.com>
2015-10-10 01:34:36 +08: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