222 Commits

Author SHA1 Message Date
Sam Ford
4a4f7a541a
Cask: Initialize yet more instance variables
I previously added some instance variables in `Cask::DSL` to its
`initialize` method but I missed some last time, so we still see
warnings like `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.`

This initializes more instance variables in `Cask` classes to resolve
other situations where this warning may occur. I've been testing this
for a while and haven't see any warnings with these changes but
there's always a chance that there's still more work to be done.
2025-06-13 08:32:56 -04:00
Carlo Cabrera
7cd1972f39
Revert "cask/artifact/abstract_uninstall: fix trash_paths" 2025-05-14 01:39:47 +08:00
Eric Knibbe
0838ceda90
cask: document shell completion stanzas
Also, allow them to be given a `target:` parameter.
2025-05-09 14:47:26 -04:00
Patrick Linnane
c6a2fa335d
brew style --fix 2025-05-05 14:35:08 -07:00
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
Bo Anderson
4cda5a1aa9
cask/artifact/abstract_flight_block: fix warning in Ruby 3.4 2025-04-16 17:06:59 +01:00
Sean Molenaar
fc319f6793 feat: add tests for completion stanzas 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
Douglas Eichelberger
8763fb6d29 Resolve rubocop violations 2025-02-17 18:56:31 -08: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
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
Kristján Oddsson
3b0794a884 implement fixes and comments for DisableComment rubocop 2025-01-29 09:17:11 +00:00
Ilya Kulakov
730a3de1b9 sudo: Elevate priviliges before adding metadata after relocating a cask, if necessary
Homebrew cannot assume that target location is writable for chmod and xattr.
2025-01-20 14:35:36 -08:00
Sean Molenaar
c34b71655c feat: allow font install on linux
Apply suggestions from code review

Co-authored-by: Douglas Eichelberger <697964+dduugg@users.noreply.github.com>

feat: add linux appdir

Apply suggestions from code review

Co-authored-by: Douglas Eichelberger <697964+dduugg@users.noreply.github.com>
2025-01-19 11:14:24 +01:00
Douglas Eichelberger
9e3e1e1847 Namespace some top-level constants 2024-12-11 11:04:55 -08:00
apainintheneck
ebede56314 cask/artifact/abstract_uninstall: handle sudo trashed paths correctly
This showed a confusing message when the trash path was able to be
deleted using sudo since the untrashable array was updated but
the check was higher up for returning early.

```
==> Trashing files:
/Users/Shared/Maxon
/Users/Shared/Red Giant
~/Library/Application Support/Maxon
~/Library/Application Support/Red Giant
~/Library/Caches/net.maxon.app-manager
~/Library/Preferences/Maxon
~/Library/Preferences/net.maxon.app-manager.plist
~/Library/Saved Application State/net.maxon.app-manager.savedState
==> Using sudo to gain ownership of path '/Users/Shared/Maxon'
==> Using sudo to gain ownership of path '/Users/Shared/Red Giant'
Warning: The following files could not be trashed, please do so manually:
==> Removing all staged versions of Cask 'maxon'
```

The warning about files not getting trashed should only be shown if
some files didn't get trashed.

Fixes https://github.com/Homebrew/brew/issues/18901
2024-12-08 15:53:59 -08:00
Bo Anderson
7308c105a4
cask: try fix a couple of permission edge cases under multi-user 2024-11-25 17:36:47 +00:00
Douglas Eichelberger
ced4a3a91f Migrate Parlour extensions to Tapioca compilers 2024-10-14 19:50:09 -07:00
Patrick Linnane
c2e2b23c50
brew style --fix
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-10-02 10:03:12 -07:00
Case Taintor
20444638f3 modifies logic to only compare versions if auto_updates is false 2024-09-26 13:41:22 +02:00
Case Taintor
31c560e578 Improve cask --adopt to only care about the installed version if auto_update is false 2024-09-26 11:59:40 +02:00
Mike McQuaid
94416e82f0
Add new odeprecated, odisabled, remove disabled code.
Prepare the usual deprecation cycle for Homebrew 4.4.0.
2024-09-24 10:15:34 +01:00
Douglas Eichelberger
f4e04c8951 Make Cask::Artifact::Installer typesafe 2024-08-18 16:10:35 -07:00
Bevan Kay
dcce0584bd
Revert "Make Cask::Artifact::Installer typesafe" 2024-08-13 08:24:20 +10:00
Douglas Eichelberger
32107f2cb3
Merge pull request #18020 from Homebrew/installer-safety
Make Cask::Artifact::Installer typesafe
2024-08-12 13:35:21 -07:00
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
Douglas Eichelberger
52b25d71f5 Make Cask::Artifact::Installer typesafe 2024-08-11 16:56:20 -07:00
Bo Anderson
ec41f66ee7
cask/artifact/installer: reset UID when running scripts 2024-07-17 06:33:08 +01:00
Kevin
c3c1528611
Revert "Use cp -c when copying files" 2024-06-17 21:17:10 -07:00
Bo Anderson
fa00d2a9fd
cask: fix trash.swift under Xcode 16 2024-06-15 03:09:50 +01:00
Daiki Mizukami
8e8d0c0248
brew style --fix 2024-06-12 12:28:42 +09:00
Daiki Mizukami
028cfe1ea6
Utils::Cp: Rename to Utils::Copy
As per review feedback:

https://github.com/Homebrew/brew/pull/17373#discussion_r1633217748
2024-06-11 20:31:34 +09:00
Daiki Mizukami
67f280eb53
Utils::Cp: Add force_system keyword argument
This fixes the test for `UnpackStrategy::Directory`, which needs the
`cp` command.
2024-06-09 07:57:56 +09:00
Daiki Mizukami
b2ddeecdd9
Utils::Cp: Remove copy prefix from method name
As per review feedback:

https://github.com/Homebrew/brew/pull/17373#pullrequestreview-2104523770

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2024-06-08 07:58:20 +09:00
Daiki Mizukami
58852106c1
Utils::Cp: Rename copy* methods to copy*_with_attributes
As per review feedback:

https://github.com/Homebrew/brew/pull/17373#pullrequestreview-2103870774
2024-06-07 19:03:33 +09:00
Daiki Mizukami
deaac7ce47
Use Utils::Cp to copy files
This replaces `FileUtils.cp` and `system_command! "cp"` with the new
`Utils::Cp` utility where it is expected that the performance
improvement outweighs the cost of the system command invocation.
2024-05-27 12:11:41 +09:00
Mike McQuaid
6e9288470e
brew style --fix 2024-05-23 17:15:43 +01:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Markus Reiter
c76170a456
Hide #to_s in docs. 2024-04-26 14:04:55 +02:00
Mike McQuaid
8baed211a7
brew style --fix 2024-04-08 19:23:33 +01:00
Bo Anderson
011dfc8f45
cask/artifact/moved: fix permission handling when removing directories 2024-03-15 21:31:37 +00:00
Mike McQuaid
a3702a28c4
cask/artifact: check the bundle version when using --adopt.
This makes `--adopt` considerably faster and more useful for application
bundles by checking the bundle version before failing to adopt the
bundle.

This could be further extended by e.g. checking if auto-updates are
enabled.

While we're here, also allow `adopt` to act a bit more like `force` in
a few other places assuming this initial check passes.
2024-03-14 10:31:31 +00:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Issy Long
f4218a6316
Fix RuboCop Performance/MapCompact offenses
- Rename an iterator variable since it would make the line too long.
2024-02-25 22:59:59 +00:00
Mike McQuaid
0d02aa3313
Merge pull request #16578 from dnicolson/fix-quick-look
Replace “QuickLook” with “Quick Look”
2024-02-04 12:09:45 +01:00
Dave Nicolson
31f09f8d30 Replace “QuickLook” with “Quick Look” 2024-02-03 23:54:04 +01:00
Douglas Eichelberger
eb7c3e52a0 Require SystemInclude only where needed 2024-01-31 11:42:01 -08:00