61 Commits

Author SHA1 Message Date
apainintheneck
6ccf21c2c9 Merge branch 'master' into add-service-block-to-formula-api 2023-03-22 20:06:32 -07:00
apainintheneck
801ee5e474 Address feedback
- style nits
- better comments for tests that are not idempotent
- moved appdir placeholder constant to global.rb
2023-03-22 19:43:49 -07:00
apainintheneck
38146893c3 api_hashable: Make API path subs generic
This turns the ability to replace common paths with placeholders
into a mixin that can be used with both Casks and Formulae.

The idea here is to make formula hash generation more consistent.
2023-03-21 23:20:42 -07:00
apainintheneck
3aae28aa0d cask: remove old prefix placeholder
This was just a temporary workaround while we
waited for the API to regenerate the JSON content.
2023-03-18 16:42:44 -07:00
Douglas Eichelberger
04fa6e24d7 Enable more typing 2023-03-13 09:08:56 -07:00
Mike McQuaid
b698cef945
brew style --fix (and a manual one) 2023-03-07 10:48:35 +00:00
Mike McQuaid
d20abb4863
brew style --fix 2023-03-03 10:45:08 +00:00
apainintheneck
c19017c6bd Make Cask#to_h work without the API
Set metadata when we load casks from the source API.

Set `@tap_git_head` manually.

Also, allow `auto_update` to receive false.
This is only done for consistency.

Stop double printing the `kext` caveat.

Handle Array elements correctly when substituting
path elements in artifacts. This affected how the
Uninstall Signal keys were evaluated (they are
represented as arrays of arrays).
2023-02-28 19:36:20 -08:00
apainintheneck
b91e93cda0 Load cask source with tap info
This info is used in the installer to
decide whether to report analytics.
2023-02-27 23:51:43 -08:00
apainintheneck
fdc2e9f3f5 Merge branch 'master' into delay-loading-from-cask-source-api 2023-02-26 14:50:13 -08:00
apainintheneck
fd62cdf636 cask: delay loading from source API
For casks with certain stanzas, *flight and language
stanzas in this case, we need to use the caskfile
to install them correctly. The JSON API is not an option.

This delays loading from the source API until just before
we try to install one of these casks. This reduces the
number of requests we make to the source API.
2023-02-25 20:54:37 -08:00
Rylan Polster
29bb0ee3bf
Set tap for casks when loading from contents via API 2023-02-25 16:24:58 -05:00
Bo Anderson
e86a8c2477
Move HOMEBREW_NO_INSTALL_FROM_API defaults to shell 2023-02-24 21:53:08 +00:00
Bo Anderson
aebc125e9c
cask: support url specs in API 2023-02-24 13:56:46 +00:00
Mike McQuaid
aeda0c473f
Merge pull request #14792 from Bo98/cask-contents-checksum
cask_loader: fix missing checksum in FromContentsLoader
2023-02-24 12:55:11 +00:00
Bo Anderson
09eb7b3dcb
cask_loader: fix missing checksum in FromContentsLoader 2023-02-24 12:09:34 +00:00
Mike McQuaid
f280ce069b
Support loading formulae/casks from subdirectories
Previously, we required all formulae and casks to be in a specific
formula or cask directory but did not check any subdirectories.

This commit allows using subdirectories for official taps, the only
ones likely to be big enough to warrant sharding in this way and to
avoid potentially breaking backwards compatibility for existing taps.

This was inspired by the most recent issues with homebrew-cask.
2023-02-24 10:57:41 +00:00
Bo Anderson
e663f532a6
Checksum Ruby source file downloads 2023-02-22 22:50:24 +00:00
Mike McQuaid
237eec8ef8
Overhaul Formula/Cask JSON generation
- Use constants for placeholders
- Monkeypatch to set `HOMEBREW_PREFIX` consistently to placeholder
- Use environment variable to set `Dir.home` consistently to placeholder
- Use `appdir` short-circuit to set `Cask#appdir` consistently to placeholder
- Use `Cask.generating_hash!` to enable "generating mode" with these patches
- Fix `Formula#caveats` from JSON

Fixes #14505
Fixes #14595
2023-02-14 14:19:40 +00:00
apainintheneck
39c6f7d6fb Stop including *flight block source in cask API
Originally we were going to try and load the *flight blocks from the API
but we ended up going with downloading the caskfile for the subset of
casks that need this functionality for consisty's sake.

This reverts the following commits from most recent to oldest:
- ffc74a51fb32b66a4cd8bc41dbd076dd23d9100e
- e5616e94fe42505434c330be35eeafef2739944f
- d1490c3d5c087d00f2bca1787cce331202b195c5
- 7ca5a5d9a71a73f21bbb8555a38048f027bee89b
- 2d5d132713d0701d02d5ff33e9918812d13d2a83

It also changes how *flight blocks are handled in `.to_h`.
Essentially, when *flight blocks exist they are just included
as a hash of the artifact to nil to indicate that they exist.

More information isn't necessary since we don't evaluate
the current source code in the *flight artifacts that
we get from the API.
2023-02-13 21:22:18 -08:00
Rylan Polster
f7fa5937d8
Allow brew info --json=v2 without taps with JSON API 2023-02-12 12:03:40 +00:00
Mike McQuaid
1a0f62c5dc
Merge pull request #14522 from Rylan12/api-load-booleans
Properly load booleans from the API
2023-02-06 16:06:15 +01:00
Rylan Polster
48f4769155
Properly load booleans from the API 2023-02-06 15:07:28 +01:00
apainintheneck
36ca7c95e5 Adds logging to cask loader
- extend Context to get `debug?` method
- create FromDefaultTapPathLoader to handle
  expected loading option
- log cask loader used when --debug
2023-02-05 13:36:26 -08:00
Rylan Polster
0229196ac5
Merge pull request #14503 from Rylan12/artifact-json-fix
Don't convert boolean and blank values to strings in cask artifacts API
2023-02-05 15:40:14 +01:00
Rylan Polster
5ab7f14d2b
Fix cask not found error when upgrading certain casks 2023-02-05 12:26:22 +01:00
Rylan Polster
a166be9541
Don't convert boolean and blank values to strings in cask artifacts API 2023-02-05 02:58:03 +01:00
Rylan Polster
af9ba41cb0
Merge pull request #14456 from Rylan12/api-language-support
Support `languages` when installing from the API
2023-02-03 05:23:55 -05:00
Mike McQuaid
9d6713d023
Merge branch 'master' into api-language-support 2023-02-03 08:36:23 +00:00
apainintheneck
15c1930804 Remove redundant FromAPILoader attempt
After 32a0877 this logic has been changed so it's now
always covered by `FromAPILoader.can_load?`.
2023-02-02 18:43:53 -08:00
apainintheneck
2d93cbe13f Handle merge conflict 2023-02-02 18:40:13 -08:00
apainintheneck
e0ad960025 Load cask from API with fullname
This allows homebrew/cask/caskname
to work with the FromAPILoader.

Also, creates new constant to hold the
regex to validate main tap casks.
2023-01-31 19:39:10 -08:00
Rylan Polster
32a0877cad
Remove CaskSource API 2023-01-28 02:15:00 -06:00
Rylan Polster
c1fdcbdd0e
Support languages when installing from the API 2023-01-28 01:42:19 -06:00
Mike McQuaid
fd18c7b0ac
Tweak cask-source API handling
- Use raw.githubusercontent.com to download cask source rather than
  formulae.brew.sh. This allows us to remove these files
- output the tap's current `HEAD` for both formulae and cask JSON
- use this `HEAD` for the cask-source API to get the exact file on
  raw.githubusercontent.com rather than just whatever is newest (which
  is what the previous API did)
- set the `Tap` correctly when creating a `Cask` from the API
- if the `formula.json` file exists: print its modified time include
  `brew config`
- memoize `tap.git_head` as we'll be calling it a lot in the same
  process with the same value
2023-01-26 17:36:40 +00:00
Mike McQuaid
ab1fbb7fa9
cask_loader: fixup artifacts/caveats from JSON API.
These are mapped to generic versions in `cask/cask.rb` so we need to map
them back for them to be correct.
2023-01-25 15:07:44 +00:00
Rylan Polster
4c8c547027
Add clarifying comment 2023-01-11 13:16:34 -05:00
Rylan Polster
6468897458
Fix depends_on arch: when loading casks from API 2023-01-10 12:35:39 -05:00
Rylan Polster
ec8adb617e
Use cask-source API when needed 2023-01-06 02:46:22 -05:00
Rylan Polster
ffc74a51fb
Load *flight blocks from API 2023-01-06 02:46:22 -05:00
Rylan Polster
374b61584b
Load casks from the JSON API with HOMEBREW_INSTALL_FROM_API 2023-01-06 02:46:21 -05:00
Mike McQuaid
37be5bea52
dev-cmd/edit: handle editing with install_from_api.
Before this change, this would fail every time, even when available on
disk (which was not the case for formulae).

With this change, it will attempt to find it from a tap on disk and only
fail if it cannot be found in any.
2023-01-04 13:51:21 +00:00
Ian Gregory
cdc707fa38 Cache compiled regexes
Improves performance of `brew info --json=v2 --eval-all` by about 15–20%
2022-10-27 02:06:22 -04:00
Rylan Polster
55da9f293d
Cleanup Cask::Caskroom::casks 2022-06-26 14:24:05 -04:00
Rylan Polster
b63474398e
Always prefer loading from API when HOMEBREW_INSTALL_FROM_API is set 2022-06-17 13:54:05 -04:00
Rylan Polster
1e536217b2
Streamline loading casks from API 2022-06-15 16:35:49 -04:00
Rylan Polster
ea2e40c69a
Add Cask::Cask#source to return cask's source code 2021-08-14 16:18:13 -04:00
nandahkrishna
585ec90878
cask_loader: do not auto-tap in FromTapLoader 2021-03-11 21:09:42 +05:30
EricFromCanada
6fc116318e fixes for grammar and wording 2021-01-26 16:19:47 -05:00
Markus Reiter
da9289eff0 Add more type signatures. 2020-11-13 12:26:36 +01:00