112 Commits

Author SHA1 Message Date
Markus Reiter
76d8d6c840
Add type signatures. 2024-02-08 16:30:08 +01:00
Issy Long
f682147598
Fix RuboCop Style/RedundantFreeze offenses 2024-01-18 22:20:01 +00:00
apainintheneck
779d90082d cli/parser: rescue formula specification errors
This came up recently where an outdated formula definition
caused the program to crash with an ambiguous message when
a user wanted to upgrade a cask instead. Catching these errors
allows them to get handled later on improving error messages
and defaults. Now if the only formula with the given name is
invalid it will default to using the cask unless --formula is
specified.

- https://github.com/Homebrew/brew/issues/16123
2023-10-21 17:15:26 -07:00
apainintheneck
23b277bbd7 cli/named_args: better handle name conflicts in #to_paths
Before we used to evaluate all named arguments as local paths
first. This means that the following could be a name conflict.

$ brew edit src

If there was a local file or directory named src, it would default
to that. Otherwise it would search for a formula/cask with the
same name and return that.

Now it will only default to the local path if the named argument
starts or ends with a slash ('/') or includes a period ('.').
This means that in the event of a name clash with a normal package
name it will default to the package instead of the local file.

It also fixes an edge case where the following would be interpreted
as a tap name.

$ brew edit /src
2023-10-01 15:51:02 -07:00
apainintheneck
b1c47969a6 cli/named_args: expand paths in #to_paths
This will make the output clearer for `brew edit --print-path`.
2023-09-27 23:16:20 -07:00
Bo Anderson
ba2ecede1a
cli/named_args: don't interpret --formula/--cask args as paths 2023-09-27 17:56:42 +01: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
Bo Anderson
68289f1165
Add without_api specifier for CLI named args 2023-06-22 01:57:28 +01:00
Markus Reiter
486c3765ce
Add --os=all and --arch=all options. 2023-05-17 15:26:46 +02:00
Markus Reiter
a3231a03fa
Implement cask renames. 2023-05-12 21:17:30 +02: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
Douglas Eichelberger
04f7258009 brew style --fix 2023-03-13 11:24:49 -07:00
Douglas Eichelberger
e5a392c256 T.unsafe is now safe 2023-03-13 10:46:39 -07:00
Douglas Eichelberger
d98b7845d3 Enable typing in misc files 2023-03-03 08:29:26 -08:00
EricFromCanada
dfc9906184
internal messaging fixes 2023-02-10 23:17:16 -05:00
Rylan Polster
1e536217b2
Streamline loading casks from API 2022-06-15 16:35:49 -04:00
Bo Anderson
1d36c42fb7
Support offline usage under HOMEBREW_INSTALL_FROM_API 2022-06-14 16:06:05 -04:00
Bevan Kay
183cbe0001
named_args: handle additional cask exception 2022-06-02 12:21:44 +10:00
Mike McQuaid
fdefffc0a5
named_args: better handle keg-like casks.
Need to ensure we're using the installed caskfile when it's requested
and readable.

Follow-up from https://github.com/Homebrew/brew/pull/13289 addressing
https://github.com/Homebrew/brew/pull/13289#discussion_r884853652
2022-05-31 09:06:52 +01:00
Mike McQuaid
94148c3bc8
Fix handling unreadable casks
When casks are unreadable (e.g. have invalid syntax, the cask file
cannot be found) then it's not been possible to uninstall them, list
them or perform any operation which iterates through all casks.

Handle these various cases by falling back to creating a `Cask::Cask`
object using just the name/token and latest installed version on disk.

This provides enough functionality to be able to verbosely list these
casks, not error on listing and, most importantly, uninstall/reinstall
them.

Fixes https://github.com/Homebrew/homebrew-cask/issues/62223
2022-05-16 17:27:13 -04:00
Mike McQuaid
38e1b3d64b
Deprecations, disables, deletions for 3.4.0 2022-02-22 14:28:32 +00:00
fn ⌃ ⌥
9b611be759 Print given argument instead of rename if matching keg not found 2021-11-24 11:39:52 -08:00
EricFromCanada
6e0e96eb1d
list: raise NoSuchKegError if formula exists but isn't installed 2021-11-11 17:40:32 -05:00
Rylan Polster
0b8032d421
Document HOMEBREW_INSTALL_FROM_API 2021-10-22 12:37:57 -04:00
Nathan Woythaler
0b8605bcbe
Add --print-path flag to brew edit
Add a `--print-path` flag to `brew edit`, in order to print the source `.rb`
file of both casks and formulae. In order to prevent faulty reporting, `brew
formula $SOME_CASK` will now error out if a cask matches, but a formula does
not.
2021-10-20 09:04:59 +01:00
Mike McQuaid
f65d525693
Deprecations/disables for 3.3.0/4.0.0.
Deprecate, disable and remove code for Homebrew 3.3.0 or 4.0.0
(whichever the next release ends up being).
2021-10-19 16:36:42 +01:00
hyuraku
2347bfdb92 use default_kegs 2021-09-09 22:16:45 +09:00
Rylan Polster
5d536d66fc
Rename HOMEBREW_JSON_CORE to HOMEBREW_INSTALL_FROM_API 2021-08-27 00:24:15 -04:00
Rylan Polster
99635bf3ae
Remove need for homebrew/cask to be tapped 2021-08-14 16:17:26 -04:00
Connor Mann
92717b6f6f
Update Library/Homebrew/cli/named_args.rb
Co-authored-by: Rylan Polster <rslpolster@gmail.com>
2021-08-12 09:16:23 -04:00
Connor Mann
a566c53db8
Add resolve_latest_keg revision secondary sort 2021-08-11 20:07:28 -04:00
Rylan Polster
90bbe8bb03
Merge pull request #11831 from Rylan12/api-cleanup
Refactor API methods
2021-08-09 12:32:55 -04:00
Connor Mann
363bcbd72a
Sort head kegs by tab modification time 2021-08-06 21:27:21 -04:00
Rylan Polster
737dd1654b
Refactor API methods 2021-08-06 04:31:27 -04:00
Connor Mann
3dde12c634
Handle only HEAD kegs in to_latest_kegs 2021-08-04 18:51:39 -04:00
Rylan Polster
1e34b69cd4
Prioritize installing from JSON if env var is set 2021-07-12 03:23:42 -04:00
Rylan Polster
e316c4f013
Rename Utils::BottleAPI to BottleAPI 2021-07-05 11:45:15 -04:00
Rylan Polster
36dd69dd60
Rename download_bottles to fetch_bottles 2021-07-05 10:55:34 -04:00
Rylan Polster
22f986b89a
Install formulae from JSON files 2021-07-04 12:38:59 -04:00
Mike McQuaid
30a65342e8
Deprecate, disable, delete code for Homebrew 3.2.0
Do the usual deprecation, disable, delete dance for Homebrew 3.2.0.
2021-06-17 11:34:32 +01:00
Connor Mann
0a1614286d Fix style 2021-05-24 08:44:36 -04:00
Connor Mann
73ef297dd5
Update Library/Homebrew/cli/named_args.rb
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2021-05-21 11:55:30 -04:00
Connor Mann
3b0243900f
Update Library/Homebrew/cli/named_args.rb
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2021-05-21 11:55:11 -04:00
Connor Mann
6f005caf07 Rename memoized variable 2021-05-20 15:10:20 -04:00
Connor Mann
fa9a525d32 Add to_latest_kegs 2021-05-20 12:58:23 -04:00
Connor Mann
b1ce7ef647
Update Library/Homebrew/cli/named_args.rb
Co-authored-by: Rylan Polster <rslpolster@gmail.com>
2021-05-20 11:30:22 -04:00
Connor Mann
26a3218fb0 Deprecate method: :keg 2021-05-20 09:53:31 -04:00
Connor Mann
49aa057188 Rename resolve_keg to resolve_default_keg 2021-05-19 10:29:40 -04:00