1648 Commits

Author SHA1 Message Date
apainintheneck
7e05a9b574 cmd/audit: improve performance of versioned formula names
There is a check for other versioned formula with the same name
in the file audit. This just memoizes all of the versioned
formulae in a tap during the first call and then uses that much
shorter list everytime it checks for things.
2023-09-16 09:18:13 -07:00
Bo Anderson
be2834ace8
formula: add global caching for declared_runtime_dependencies 2023-09-15 03:08:27 +01:00
Sam Ford
578c935bcf
Formula, BuildError: Update type signatures
We're seeing type errors when building formulae that use something
like `xcodebuild ..., "-arch", Hardware::CPU.arch`, since `CPU.arch`
is a symbol. We've been addressing these issues by calling `#to_s` on
the value but there was some talk about simply expanding the type
signatures to accommodate anything that will be cast to a `String`.

There's maybe still an argument to be made for doing string conversion
in formulae but expanding the type signatures will resolve a number of
existing type errors if we simply want to rely on implicit type
casting.

Past that, this also updates the type signature for `BuildError` to
align with the `#system` signature changes, as we receive a type error
otherwise.
2023-09-13 19:16:04 -04:00
Eric Knibbe
931f762598
docs+rubydoc: various grammar/wording fixes 2023-09-11 02:26:37 -04:00
Eric Knibbe
bd659ce4d0
formula: fixes for rubydoc output
in particular, #generate_completions_from_executable
2023-09-09 14:54:45 -04:00
hyuraku
08c4e6848e remove useless require 2023-09-08 22:52:33 +09:00
hyuraku
adc2a2fea1 remove ARGV from Formula#all 2023-09-02 19:35:22 +09:00
Branch Vincent
f8ab19d187
formula: drop old pip feature flag 2023-08-26 12:48:16 +01:00
Mike McQuaid
d313e8b027
Merge pull request #15824 from dduugg/inreplace-static
Make inreplace a purely static method v2
2023-08-08 12:32:10 +01:00
Douglas Eichelberger
5d5c22e104 Replace integration test with unit test 2023-08-07 18:32:08 -07:00
Douglas Eichelberger
2b29c498fa s/blk/block 2023-08-07 17:26:46 -07:00
Branch Vincent
61d23fef53
formula: use pip's --no-compile 2023-08-05 16:39:29 -07:00
Douglas Eichelberger
864f31e52a Forward block argument 2023-08-04 16:20:56 -07:00
Douglas Eichelberger
efd02b956d Revert "Revert "Make inreplace a purely static method""
This reverts commit 8656caa67ce2dd9ec6484969b183c1fd7805451e.
2023-08-04 16:20:38 -07:00
Alexander Bayandin
8656caa67c
Revert "Make inreplace a purely static method" 2023-08-03 16:16:19 +01:00
Douglas Eichelberger
da33049c69 Resolve Style/OptionalBooleanParameter violation 2023-08-02 14:47:06 -07:00
Douglas Eichelberger
2ad87f87d5 Make inreplace a purely static method 2023-08-02 09:44:18 -07:00
Douglas Eichelberger
8d8dac0de4 Narrow member type of inreplace paths enumerable 2023-08-01 09:22:48 -07:00
Douglas Eichelberger
da8a062cfc Widen paths type in Formula#inreplace 2023-07-31 11:31:35 -07:00
Branch Vincent
768a8085a7
formula: suppress std args for cabal, meson, pip 2023-07-31 08:53:34 -07:00
Branch Vincent
8b016141cd
formula: fix std_cargo_args type error 2023-07-25 20:41:16 -07:00
Douglas Eichelberger
a4ca2b9e0b remove unnecessary casts 2023-07-24 22:08:52 -07:00
Douglas Eichelberger
b5c145cfa9 Add init sig as well 2023-07-24 14:12:47 -07:00
Douglas Eichelberger
08e46c18cd Add type to Formula attrs 2023-07-24 14:12:36 -07:00
Douglas Eichelberger
a46430a390 Fix type error when running 'brew doctor' 2023-07-24 07:00:26 -07:00
Mike McQuaid
3b3300546b
Merge pull request #15741 from dduugg/stict-type-string_inreplace_extension 2023-07-24 08:40:46 +01:00
Douglas Eichelberger
6d53c52d2c Add sigs to Formula boolean methods 2023-07-23 21:05:02 -07:00
Branch Vincent
b7775fa007
formula: fix std_pip_args with empty prefix 2023-07-23 20:35:44 -07:00
Douglas Eichelberger
09885cad3a Add sigs to Formula pathname methods 2023-07-23 18:42:06 -07:00
Carlo Cabrera
a1bf42cc89
formula: fix inreplace typechecking error
Fixes

        TypeError: Parameter 'before': Expected type T.nilable(T.any(Regexp, String)), got type Pathname with value #<Pathname:/opt/homebrew/Cellar/php/8.2.8/lib/php>
      Caller: /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/php.rb:207
      Definition: /opt/homebrew/Library/Homebrew/formula.rb:2483

https://github.com/Homebrew/homebrew-core/actions/runs/5635089949/job/15265751616?pr=137335#step:3:1732
2023-07-23 15:23:45 +08:00
Carlo Cabrera
d0b0fa5421
formula: fix typechecking error in std_cmake_args
`install_libdir` is sometimes passed a `Pathname`.
2023-07-23 01:52:58 +08:00
Douglas Eichelberger
f55c2a4e8e Fix type error 2023-07-21 20:09:00 -07:00
Douglas Eichelberger
11a9086b89 Fix inreplace sig
Implicit Pathname strings strike again
2023-07-21 20:02:59 -07:00
Branch Vincent
9597f455aa
formula: add std_pip_args 2023-07-19 20:02:47 -07: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
Mike McQuaid
7da934f7e2
Deprecate/disable/delete code.
The next release after this is merged will be 4.1.0.

Co-authored-by: Markus Reiter <me@reitermark.us>
2023-07-06 16:56:20 +01:00
Mike McQuaid
229a1f6c1e
Remove Tap#versioned_formula_files
This doesn't work with the API and the single caller can be
refactored to not need it instead.
2023-07-05 16:28:44 +01:00
Bo Anderson
c4077aa076
Support head deps & uses_from_macos bounds in API; strip implicit deps 2023-07-04 13:40:58 +01:00
Bo Anderson
d1b923f314
Introduce UsesFromMacOSDependency
Add Formula#declared_deps and SoftwareSpec#declared_deps
2023-07-04 13:40:55 +01:00
Mike McQuaid
cd414bd95f
Include core formulae from API in Formula.all.
This is needed to allow `Formula.all` to behave as expected when using
the API. Let's also (immediately, because it's broken) deprecate the
`CoreTap#formula_files` method.

Fixes #15122
2023-06-28 15:27:20 +01:00
Bo Anderson
8dc2e80a98
Significantly improve install speeds with smarter postinstall detection 2023-06-22 03:06:45 +01:00
Bo Anderson
3e99873fa4
formula: fix variations not being generated for instance on_os usage 2023-06-19 03:47:50 +01:00
Markus Reiter
e9bfcb9296
Merge pull request #15225 from reitermarkus/audit-os-arch
Add `--os=all` and `--arch=all` options for `brew audit`.
2023-05-19 15:03:32 +02:00
Kevin
946478aed4
Merge pull request #15396 from apainintheneck/custom-service-name
Custom service name
2023-05-17 22:09:31 -07:00
Markus Reiter
486c3765ce
Add --os=all and --arch=all options. 2023-05-17 15:26:46 +02:00
Markus Reiter
f60612e6b2
Add Formula#loaded_from_api?. 2023-05-15 13:58:33 +02:00
Markus Reiter
94d6213196
Merge pull request #15418 from reitermarkus/simplify-hash-merge
Simplify hash merge.
2023-05-14 21:41:39 +02:00
Markus Reiter
d2231086bd
Merge pull request #15420 from reitermarkus/simulate-system-with
Add `SimulateSystem::with`.
2023-05-14 21:41:20 +02:00
Markus Reiter
0d56b97b07
Add SimulateSystem::with. 2023-05-14 01:45:04 +02:00
apainintheneck
1111706378 service: add custom service name DSL
The main thing is that this DSL allows us to provide an
interface that can be serialized to the JSON API.

Changes:
- Homebrew::Service
  - Adds `#service_name` and `#plist_name` methods
    - Each is now included in the `#serialize` method as well
  - Eval block on instantiation
    - Before we lazy evaluated this but the cost is not significant
      and it complicated the code a bunch. This only gets called
      during install, when evaluating caveats and in the `brew service`
      command. It skips this evaluation if the service block isn't there.
  - Add `#command?` helper to avoid `#command.blank?` and `#command.present?`
- Formula
  - `#service` now returns a service whenever it's called. This call is
    hidden behind a call to `#service?` most of the time anyway so this
    should be fine.
  - `#plist_name` and `#service_name` now call the methods of the same name
    on the service class. This should have already been in the service object
    to begin with and keeping these methods here helps preserve backwards
    compatibility with people who were overwriting these methods before.
- Caveats
  - Prefer `service#command?`
  - Add helpers for checking on service commands
    - This duplicates some of the work in `brew services`. Maybe we should
      merge that repo in at some point.
  - Check for installed service at `#plist_name` or `#service_name`. I think
    this should be used instead of `Keg#plist_installed?` which checked for any plist file.
    We should think about deprecating `#plist_installed?` in the future.
  - Stop using `ps aux | grep #{formula.plist_name}` to check for service files
    because it was inaccurate (it always returns true on my machine) because the grep
    process is started before the ps process.
  - Note: The behavior is the same as it was before. This means that caveats
    only show up for custom service files on install or if they're already installed.
    Otherwise it won't show up in `brew info`. This is because it has to check
    first if the service file has been installed.
- Utils::Service
  - Add utils for evaluating if a service is installed and running. This duplicates
    some of the work already found in `brew services`. We should seriously consider
    merging `brew services` with the main brew repo in the future since it's already
    tightly coupled to the code in the main repo.
- Formulary.load_formula_from_api
  - Be more explicit about which types can be deserialized into run params since
    it is now possible for run params to be nil.
- Update and add tests
2023-05-13 14:53:01 -07:00