2300 Commits

Author SHA1 Message Date
Carlo Cabrera
f816a39d1f
cask/artifact/abstract_uninstall: fix trash_paths
This is currently behaving incorrectly when calling `trash.swift` fails
due to lack of permissions. In this instance, `trash.swift` prints

    error: permissionDenied

to stdout, and this is incorrectly parsed as having successfully trashed
a file named `error` and another named ` permissionDenied`.

Let's fix this by ensuring that:
- any paths in `trashed` are in the `paths` that we wanted to trash in
  the first place
- define `untrashable` by removing the `trashed` paths from `paths`
2025-04-24 18:03:07 +08:00
Sam Ford
4917fb2c93
Cask::DSL: Remove duplicate token definition
I inadvertently duplicated the `@token` instance variable definition
in `Cask::DSL#initiailize`, so this removes the duplicate. This
didn't have any noticeable effect because it was redefined afterward,
so this is just a bit of tidying up.
2025-04-23 09:37:05 -04:00
Sam Ford
c0f23acdcd
Cask::Auditor: update language_blocks condition
I recently modified `Cask::DSL` to define instance variables in the
`#initialize` method and this involved some changes to the `language`,
`language_eval`, and `languages` methods. One of those was to
initialize `@language_blocks` to an empty hash instead of using a
`nil` default. I updated the related condition in the `language_eval`
method but I missed that `language_blocks` is used in `Cask::Auditor`
and it specifically relies on a false-y value to check if the variable
is set. An empty hash isn't false-y, so this is causing issues for
`brew audit`.

This updates the condition in `Cask::Auditor` to check for a non-empty
hash instead, which resolves the issue.
2025-04-23 09:19:41 -04:00
Mike McQuaid
141414a3c3
Merge pull request #19807 from Homebrew/downloadable-fixes
Cleanup Downloadable variables and types
2025-04-23 07:24:19 +00:00
Sam Ford
6f511ee4e2
Cask::DSL: initialize more instance variables
I recently updated `Cask::DSL` to define instance variables in
`#initialize` to get us closer to resolving a "shape variation"
warning from Ruby. The reason why we continued to receive this warning
after the previous changes is because I overlooked the variables that
are set using `set_unique_stanza`.

The tricky part about those instance variables is that we need to be
able to identify if they've been set. I've handled this by using a
`nil` initial value and updating the `instance_variable_defined?`
condition to check for a non-`nil` value instead. This works for these
variables but it would be a problem if we ever have a DSL method that
accepts a `nil` argument.
2025-04-22 23:21:05 -04:00
Bo Anderson
35f874c036
Cleanup Downloadable variables and types 2025-04-23 03:30:15 +01:00
Sam Ford
5b5c460ab9
Cask::DSL: define instance variables in initialize
We're now seeing warnings related to the cask DSL surfaced by Ruby
3.4:

```
/opt/homebrew/Library/Homebrew/cask/dsl.rb:456: warning: The class
Cask::DSL reached 8 shape variations, instance variables accesses
will be slower and memory usage increased.
It is recommended to define instance variables in a consistent order,
for instance by eagerly defining them all in the #initialize method.
```

I've been working on upgrading `Cask::DSL` to `typed: strict` and
part of that involves defining all of the instance variables in the
`initialize` method, so I've extracted this part of that work as a
way of helping to resolve the aforementioned warning. This doesn't
fully resolve the warning but it addresses what it was originally
referencing, at least.

For what it's worth, this includes some type fixes but I've only
included what's necessary to pass `brew typecheck`.
2025-04-22 18:12:33 -04:00
Sam Ford
c495aa3e63
Cask::DSL::DependsOn: add empty?, present? methods
`#present?` is called on a `DependsOn` object in `Cask::DSL` and this
is seemingly deferred to the underlying hash object but Sorbet doesn't
understand this kind of `SimpleDelegator` magic. This adds `empty?`
and `present?` methods that explicitly interact with the hash in a
way that Sorbet can understand.
2025-04-22 18:07:09 -04:00
Mike McQuaid
c9a7b62b1d
Homebrew 4.5 deprecations/disables/removals
The usual cycle of deprecating, disabling, and removing things in
Homebrew major/minor releases.
2025-04-22 17:15:23 +01:00
botantony
4fa1355be0 deprecate!/disable!: remove non-typed replacement field
Signed-off-by: botantony <antonsm21@gmail.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2025-04-21 21:13:25 +02:00
botantony
ca447e1ce9 deprecate!/disable!: replacement_formula/replacement_cask fields
Signed-off-by: botantony <antonsm21@gmail.com>
2025-04-21 21:13:25 +02:00
botantony
e594e7e0bb deprecate!/disable!: allow to specify replacement type
Signed-off-by: botantony <antonsm21@gmail.com>
2025-04-21 21:13:25 +02:00
Bo Anderson
4cda5a1aa9
cask/artifact/abstract_flight_block: fix warning in Ruby 3.4 2025-04-16 17:06:59 +01:00
Sam Ford
97cce36779
Make os available in cask livecheck blocks
Casks now support an `os` DSL method, similar to `arch`. This makes
it available in `livecheck` blocks, like we do with `arch`.
2025-04-04 09:17:32 -04:00
Bevan Kay
4852829931
cask/audit: install container deps 2025-04-02 16:34:28 +11:00
Eric Knibbe
57f764a1d8 cask/api: remove control characters from cask caveats 2025-03-24 15:43:15 -04:00
Mike McQuaid
2a7c7511c3
cask/quarantine: tweak wording.
Co-authored-by: Eric Knibbe <enk3@outlook.com>
2025-03-20 18:07:30 +00:00
Mike McQuaid
10ad72c348
quarantine: allow skipping the app management permissions prompt.
If we know that we don't care about this prompt, let's allow setting
a variable to avoid alarming users.
2025-03-20 16:22:41 +00:00
Mike McQuaid
4a4aeca424
cask/download: avoid some checksum warnings.
These are always output in CI for e.g. `brew fetch google-chrome` and
are completely unactionable by the user.

Ultimately this is not disabling any security checks, it's just changing
when a warning is output and unifying the logic with the other similar
warning.
2025-03-19 12:45:50 +00:00
Douglas Eichelberger
c9a6bd6438
Merge pull request #19475 from Homebrew/typed-system-command
refactor: Enable strict typing in download_strategy
2025-03-14 22:34:17 +00:00
Sean Molenaar
756ba2ba59 Add Linux dependency check in cask.rb 2025-03-13 21:47:17 +01:00
Sean Molenaar
9f6b421ad6 fix: check OS for macos dependency 2025-03-13 21:28:40 +01:00
Sean Molenaar
a137426839 feat: generate cask API for linux 2025-03-13 21:28:40 +01:00
Douglas Eichelberger
c48870080e
Incorporate feedback 2025-03-13 11:59:31 -07:00
Douglas Eichelberger
f183d0a398
Enable strict typing in Cask::URL 2025-03-12 19:09:52 -07:00
Douglas Eichelberger
e49a69679d
Enable strict typing in TopologicalHash 2025-03-12 19:09:52 -07:00
Douglas Eichelberger
1ca5299f40
refactor: Enable strict typing in download_strategy 2025-03-12 15:15:20 -07:00
Bevan Kay
74556fe97c
cask/utils: alllow use of @ in cask name 2025-03-12 19:57:37 +11:00
Eric Knibbe
cae1ca33ec
rmdir: ignore unreadable path errors 2025-03-11 09:48:39 -04:00
Eric Knibbe
c5ec1fa61b
cask/installer: pass more options to cask dependencies 2025-03-06 14:10:37 -05:00
Sam Ford
1ac70579eb
Cask: skip livecheck https audit for POST requests
We recently added `POST` request support to livecheck but related cask
checks are failing the `livecheck_https_availability` audit because it
calls `validate_url_for_https_availability` which calls
`Utils::Curl.curl_check_http_content` and that checks the URL using a
`GET` request. Adding `POST` request support to all of those methods
will take some work, so this adds a guard to skip the audit if the
`livecheck` block uses `post_form` or `post_json`. This isn't ideal
but it will allow us to add these `livecheck` blocks in the interim
time.

Co-authored-by: Douglas Eichelberger <d@eic.email>
2025-03-06 12:14:42 -05:00
Sean Molenaar
fc319f6793 feat: add tests for completion stanzas 2025-03-05 20:12:18 +01:00
Sean Molenaar
ab2b18f78c feat: add os_version for casks 2025-03-05 20:12:18 +01:00
Sean Molenaar
55b07d7fed feat: add cask shell completion 2025-03-05 20:12:18 +01:00
Douglas Eichelberger
fcf18912fe
Inline use of attr_predicate 2025-03-02 21:36:03 -08:00
Mike McQuaid
b1559f38a0
Add HOMEBREW_UPGRADE_GREEDY_CASKS
A space-separated list of casks. Homebrew will act as if `--greedy`
was passed when upgrading any cask on this list.
2025-02-25 15:34:49 +00:00
Sam Ford
a7cacfff1c
livecheck: refactor HEAD-only formula handling
The existing code for handling a `HEAD`-only formula involves two
return values that can be `nil` but this isn't apparent because the
related methods aren't typed. This adds type signatures to the
methods and updates the livecheck code to account for `nil` return
values (making it clear which methods can return `nil`).

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2025-02-20 22:39:18 -05:00
Douglas Eichelberger
cf635bc28a
Merge pull request #19314 from Homebrew/typed-dep-helpers
Enable strict typing in DependenciesHelpers
2025-02-18 18:47:06 +00:00
Douglas Eichelberger
8763fb6d29 Resolve rubocop violations 2025-02-17 18:56:31 -08:00
Sean Molenaar
22ed703c2b fix: use bottle naming for sha256
Signed-off-by: Sean Molenaar <smillerdev@me.com>
2025-02-17 14:30:44 +01:00
Rylan Polster
f874603a21 Add implicit macOS dependency to casks without explicit depends_on stanza 2025-02-17 14:30:44 +01:00
Sean Molenaar
a28fde1a8c fix sha256 on linux 2025-02-17 14:30:44 +01:00
Sean Molenaar
27a2d94c48 feat: allow zap on linux 2025-02-17 14:30:44 +01:00
Sean Molenaar
975fe8a83f feat: allow cask binaries on linux 2025-02-17 14:30:43 +01:00
Sean Molenaar
b2ca64b207 feat: allow linux blocks in casks 2025-02-17 14:27:38 +01:00
Douglas Eichelberger
0037b1f626 Enable strict typing in DependenciesHelpers 2025-02-16 12:24:22 -08:00
zyoshoka
20e33166e1
cask/url: remove arch placeholder when checking if unversioned
This prevents casks whose `url` contains only `#{arch}` from passing
`audit_sha256_no_check_if_unversioned`.
2025-02-14 15:14:40 +09:00
Douglas Eichelberger
d8c790dddc Use delegation to create Cask DSL methods 2025-02-11 08:33:04 -08:00
apainintheneck
042d6cc97e Remove JSON v3 cask logic 2025-02-05 23:32:32 -08:00
Mike McQuaid
e227663207
cask/artifact/installer: don't reset uid if sudo is used.
This fixes handling `sudo` and EUID when using certain `script` commands
on casks e.g. adobe-creative-cloud.

Co-Authored-By: Bo Anderson <mail@boanderson.me>
2025-02-03 16:58:44 +01:00