131 Commits

Author SHA1 Message Date
Bevan Kay
bd6ab1d2b8
cask/uninstall: skip quit and signal directives when upgrading or reinstalling 2024-01-19 23:30:25 +11:00
Douglas Eichelberger
ffd761d2e9 Create dedicated Attrable mixin for attr_ methods 2023-12-28 11:46:27 -08:00
Rylan Polster
6431822e7b
Apply feedback 2023-12-16 20:18:35 -05:00
Rylan Polster
641a80475e
Update cask logic to handle deprecations and disables 2023-12-16 20:01:47 -05:00
Douglas Eichelberger
00ba09d73d Remove use of ActiveSupport try 2023-11-05 09:28:19 -08:00
Mike McQuaid
daa175e760
cask/installer: remove outdated comment. 2023-09-03 09:09:14 -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
apainintheneck
c9dea04bd4 cmd/install: upgrade already installed casks
Previously, the behavior was to warn users that a cask was already
installed and then skip modifying the installed version. This is
different to how we handled things with formulas. For them we would
upgrade any already installed formulas. This just brings casks in line
with what we already do with formulas.

Changes:
- cmd/install: Upgrade already installed casks if HOMEBREW_NO_INSTALL_UPGRADE
  is not set
- env_config: Update wording of HOMEBREW_NO_INSTALL_UPGRADE to include casks
- remove error that was only used to alert about already installed casks

Note:
- The upgrade command for casks defaults to --greedy when you pass named casks
  to the command which means that this will always default to that behavior
  since you must specify the name of the cask when installing.
2023-07-23 18:50:39 -07:00
Mike McQuaid
3dabf504bd
Merge pull request #15176 from reitermarkus/cask-renames
Implement cask renames.
2023-05-14 19:46:56 +01:00
JBYoshi
ad8ce82673
Fix typing on revert_upgrade().
Also adds several type signature checks to test for these errors.
2023-05-12 14:53:27 -05:00
Markus Reiter
a3231a03fa
Implement cask renames. 2023-05-12 21:17:30 +02:00
Mike McQuaid
0e387fee8c
Merge pull request #15138 from JBYoshi/cask-move-contents
Don't remove cask directories when upgrading.
2023-05-04 11:43:44 +01:00
JBYoshi
3e249a9428
Improve styling. 2023-05-03 11:29:01 -05:00
Bo Anderson
44f058edb5
Refactor formula, cask and Ruby source downloads to use shared code 2023-04-27 23:23:07 +01:00
JBYoshi
84fe93e5d7
Remove successor behavior for zapping. 2023-04-27 10:40:45 -05:00
JBYoshi
a1571702d3
Merge remote-tracking branch 'origin/master' into cask-move-contents 2023-04-25 15:44:29 -05: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
JBYoshi
07fdbd3fd9
Handle zap successor. 2023-04-24 17:08:13 -05:00
JBYoshi
2e85f2beb2
Merge remote-tracking branch 'origin/master' into cask-move-contents 2023-04-15 21:37:56 -05:00
JBYoshi
9fedaee462
Only keep empty directories when the new version also has them. 2023-04-08 16:13:12 -05:00
Markus Reiter
844db75361
Add source paths to API. 2023-04-07 15:20:01 +02:00
JBYoshi
dcc4ae76e8
Also keep app directories with "brew reinstall". 2023-04-04 11:36:27 -05:00
JBYoshi
8c4f29d983
Don't remove cask directories when upgrading.
Fixes Homebrew/homebrew-cask#102721.
2023-04-03 18:48:24 -05:00
Mike McQuaid
8bf8393b89
Merge pull request #15021 from MikeMcQuaid/influxdb_cardinality
analytics: improve InfluxDB cardinality
2023-03-20 15:54:17 +00:00
Mike McQuaid
4d8445e29d
analytics: improve InfluxDB cardinality
- roll InfluxDB token (we need to report to a new bucket to fix implicit schema)
- adjust various parameters
- separate default tags and fields
- send more fields and fewer tags (tags should have low cardinality)
- use `--data-binary` to match InfluxDB documentation
- document second precision for greater InfluxDB performance
- pass through tap name, formula/cask name, options separately
- pass `devcmdrun` as a tag
- avoid sending very high-cardinality `OS_VERSION` values
2023-03-20 15:26:47 +00:00
Dustin Rodrigues
b776fb32de
change includecount to include_count for readability 2023-03-20 07:23:17 -04:00
Dustin Rodrigues
e5fba88035
use includecount argument in pluralize 2023-03-19 23:35:47 -04:00
Douglas Eichelberger
abfe29040b Enable types in Library/Homebrew/cask 2023-03-18 16:03:10 -07:00
Markus Reiter
2955f63921
Remove artifact debug output. 2023-03-13 19:24:53 +01: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
Mike McQuaid
d0e03fc425
Merge pull request #14820 from apainintheneck/delay-loading-from-cask-source-api
Delay loading from cask source api
2023-02-28 11:50:10 +00: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
Douglas Eichelberger
0eccc0e987 git grep -l Utils::Inflection | xargs gsed -i 's|Utils::Inflection|Utils|g' 2023-02-27 20:18:27 -08:00
Douglas Eichelberger
eb2b990575 Port more call sites 2023-02-27 20:17:33 -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
Sean Molenaar
50e9247da4
fix: add better keys and fuller values to influxDB analytics 2023-02-15 14:12:05 +01:00
Bo Anderson
7ef0c48362
Fix analytics handling when core/cask taps are untapped 2023-02-15 05:31:08 +00:00
Rylan Polster
5ab7f14d2b
Fix cask not found error when upgrading certain casks 2023-02-05 12:26:22 +01:00
Sean Molenaar
59ebdab2b7
analytics: switch to InfluxDB for logging 2023-01-19 18:15:27 +01:00
Rylan Polster
3c4f60c604
Create metadata subdirectory when needed 2023-01-08 02:45:56 -05:00
Mike McQuaid
20a200bdb7
cask/installer: ensure config_path exists.
I encountered this when installing `microsoft-edge`.

Perhaps `HOMEBREW_INSTALL_FROM_API` related.
2023-01-07 19:44:44 +00:00
Ian Gregory
a715dec49d Add --adopt switch
Allows `brew install` & co. to adopt existing cask artifacts that are
identical to those being installed.

Discussion: #14006
2022-10-21 23:28:51 -04:00
apainintheneck
c322f4fb90 cask/installer.rb: Stopped including Staged 2022-07-11 17:13:16 -07:00
apainintheneck
4dce389aa7 Remove download sha file from .metadata dir when uninstalling casks 2022-06-05 13:00:20 -07:00
apainintheneck
6f06236bca Fix :svn download errors with :latest casks 2022-06-01 09:04:54 -07:00
apainintheneck
b85f407e95 Only upgrade :latest casks when --greedy and the cask has been updated
A sha256 hash of the previous download is stored and compared with
new downloads before updating :latest casks. This prevents unnecessary
reinstalls when the cask hasn't been updated.

Move download path to cask from installer to prevent unnecessary
redownloads of casks.
2022-05-17 16:15:05 -07:00
apainintheneck
0dd3764041 Allow casks with outdated caskfiles to be reinstalled
The problem occurred when calling `brew reinstall` on a cask
with an out of date caskfile.

To solve the problem Cask::Installer#uninstall_existing_cask has been changed to
catch a possible CaskInvalidError when trying to load outdated
caskfiles using Cask::CaskLoader#load.
2022-05-02 23:39:18 -07:00
Issy Long
0b6b2f04da
cask/reinstall: Support --zap for entirely purging cask files
- The `brew uninstall` command has `--zap`, so let's make `brew
  reinstall` have parity here for a better user experience. (Requested
  in issue 12983.)
- It feels weird that to get my new reinstall test to pass I had to add
  `--zap` to `cask/cmd/install.rb`, not `cask/cmd/reinstall.rb` to get
  the tests to pass. But the `brew reinstall --cask caffeine --zap`
  command worked fine all the time. The CLI argument parser from the
  test run was complaining about not knowing what `zap` was. As a
  result, `--zap` now shows up as a switch in `brew install --help`
  which I'm not 100% convinced is the desired UX. But I've edited the
  description accordingly to specify that it will only work on
  `reinstall` operations (and `--zap` on `install` is a no-op).

```
issyl0 at pictor in /opt/homebrew on reinstall-cask-zap
❯ brew reinstall --cask caffeine --zap
==> Downloading https://github.com/IntelliScape/caffeine/releases/download/1.1.3/Caffeine.dmg
Already downloaded: /Users/issyl0/Library/Caches/Homebrew/downloads/3d6ccfdd3b8d0ab37d1c2468d6e69078c2d31d3b12bf51947c4db21e5f376af2--Caffeine.dmg
==> Implied `brew uninstall --cask caffeine`
==> Backing App 'Caffeine.app' up to '/opt/homebrew/Caskroom/caffeine/1.1.3/Caffeine.app'
==> Removing App '/Applications/Caffeine.app'
==> Dispatching zap stanza
==> Trashing files:
~/Library/Application Support/com.intelliscapesolutions.caffeine
~/Library/Preferences/com.intelliscapesolutions.caffeine.plist
~/Library/Caches/com.intelliscapesolutions.caffeine
~/Library/HTTPStoages/com.intelliscapesolutions.caffeine.binarycookies
==> Removing all staged versions of Cask 'caffeine'
==> Installing Cask caffeine
==> Moving App 'Caffeine.app' to '/Applications/Caffeine.app'
🍺  caffeine was successfully installed!
```
2022-04-09 16:37:23 +01:00
fn ⌃ ⌥
04710be2a8
install: fix --skip-cask-deps message 2021-09-27 18:25:39 -07:00