73 Commits

Author SHA1 Message Date
Bo Anderson
af7d744af0
Fixes for Ruby 3 2023-09-29 05:25:48 +01:00
Mike McQuaid
b7114651ac
utils/curl: include or use explicitly.
Include or use `Utils::Curl` explicitly everywhere it is used.
2023-09-04 22:17:57 -04:00
apainintheneck
51387287f7 Handle nil urls in cask installer and API cask loader
The goal here is to handle the case where a cask might have a nil
url stanza because that cask is not available on the current version
of macOS or the given architecture. This just moves those checks
from the end of the `Cask::Installer#fetch` method to the beginning
so that we don't try and download casks that are missing urls.

This will now provide a helpful error message like so:
```
Error: This software does not run on macOS versions older than Big Sur.
```

Beyond that it no longer tries to run the url stanza with a nil value
when loading casks from the API.
2023-09-02 20:56:36 -07:00
Mike McQuaid
b3c33d34ab
Various sharding fixes
- Load paths with no API when needed (e.g. for `brew edit`)
- Use no API mode for `brew log` as it's needed there
- Define sharding format for homebrew-cask and homebrew-core inside
  `Tap` methods
- Create new formulae/casks in location defined by these `Tap` methods
- Fix a bug in Formulary that made sharded formulae lookup less
  efficient (and possibly broke it for core and some API usage)
- Fix various other hardcoded Formula/Cask directory assumptions

Co-authored-by: Bo Anderson <mail@boanderson.me>
2023-08-04 16:43:13 +01:00
Eric Knibbe
b3ecd91f97
dev-cmd/edit: suggest tapping core repositories 2023-08-01 13:39:28 -04:00
Mike McQuaid
c940e15a5c
Use HOMEBREW_CELLAR_PLACEHOLDER
Similarly to HOMEBREW_PREFIX_PLACEHOLDER, this allows the substitution
of HOMEBREW_CELLAR in JSON output when using the API.

Fixes #15668.
2023-07-18 10:59:27 +01:00
Bo Anderson
ba02c669e1
Introduce CoreCaskTap class 2023-07-13 20:33:26 +01:00
Markus Reiter
a3231a03fa
Implement cask renames. 2023-05-12 21:17:30 +02:00
Markus Reiter
8274920217
Rename OS::Mac::Version to MacOSVersion. 2023-05-09 05:08:38 +02:00
Bo Anderson
44f058edb5
Refactor formula, cask and Ruby source downloads to use shared code 2023-04-27 23:23:07 +01:00
Douglas Eichelberger
08af78a2a5 brew style --fix 2023-04-25 09:26:24 -07:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
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